Click here to Skip to main content
15,667,014 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two tables namely Table1 ,Table2 and two schemas Sch1,Sch2 in my database and the tables present in both the schemas.
like this:

i have a UI page which contains, a drop down and three tabs.

From a UI page, user will select one schema from the drop down, then the data related to that schema should be loaded to a grid. user has an option to create a new schema with tables mentioned above. that means in future we may get lot of schemas each with the same table structure.

I need to design a data model, that handles all these. as the schema names can be changing, i need to create more dynamic kind of Entity Framework.

can anybody suggest best way to do it?

I did it in the Following way:
Class myDataContext: DbContext
     static string targetSchema=string.empty;
     public myDataContext(string connectionString,string Schemaname):base(connectionString)
      public override void OnModelCreation(ModelBuilder)


I'm not sure about the inherent evil in the code. Please suggest me if there is any better way to do it
Thanks in advance :)
Updated 8-Aug-14 2:50am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900