How do i map dynamic tables with different schema names
-
Thursday, April 12, 2012 10:43 AM
have table with Names such as
JS Engineering Services$Web User Setup Header and Sachin Sales & Service Pvt Ltd$Web User Setup Header
how do i map these tables with Ado.net Entity framework POCO Code first approach ? The table structures are the same . I have done POCO with Single Table names and Schema as Dbo just declaring table like
Web User Setup.
Also alongwith it I would like to ask That how to Create tables like Names with spaces. Something like above as i have mentioned . If we want to Create Table names with Spaces How to do it dynamically to generate a table name as
Sachin Sales & Service Pvt Ltd$Web User Setup Header
using Ado.net Entity framework in Codefirst approach ?
Can someone guide me with the above mentioned scenario how to approach it ? I just want to map the table names to selected schema like i can switch to either Sachin Sales & Service Pvt Ltd$Web User Setup Header Or else Pravat Ent Ltd$Web User Setup Header
mind it both are in same database . Like companies can be many it may be more than two companies . so schema names can be multiple. But the Table structure remains the same .
Can someone tell me how to proceed with it ?
Regards Joy
All Replies
-
Monday, April 16, 2012 8:11 AMModerator
Hi Joy,
You can use Fluent API to map your database name with schema, here is a link about the topic: http://msdn.microsoft.com/en-us/library/hh295845(v=vs.103).aspx hope it helps.
modelBuilder.Entity<Department>() .ToTable("t_ Department", "school");
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by Alan_chenModerator Tuesday, May 08, 2012 2:37 AM

