none
How to use different database/server in single MVC 4 using entity framework RRS feed

  • Question

  • Hi,

    I am using MVC 4 with Entity Framework. I am working on 3 different databases. Below is scenario,

    1) I have 2 different SQL Servers. Server1 & Server2.

    2) I am using 2 databases from Server 1 & One database from Server 2.

    3) I have created entity model for each database. Now I have questions,

    Question 1) How can I give Primary -> Foreign key constraints across server/database.

    Question 2) How can I use all 3 entity model in Single LINQ query?

    Question 3) For few requirements, I need to show single relation database digram for all 3 database? How can I do this, as when creating new database diagram it shows tables present in that database only. (In MSSQL Server)

    Experts, Please suggest the way to do this without minimal performance impact.

    Regards,

    Parag

    • Moved by CoolDadTx Monday, July 14, 2014 2:13 PM EF related
    Monday, July 14, 2014 12:19 PM

Answers

  • Question 1) How can I give Primary -> Foreign key constraints across server/database.

    You can do it across servers using T-SQL, but I doubt that EF can handle it.

    Question 2) How can I use all 3 entity model in Single LINQ query?

    You woyld have a dbContext or ObjectContext for each one of the models within the query.

    Question 3) For few requirements, I need to show single relation database digram for all 3 database? How can I do this, as when creating new database diagram it shows tables present in that database only. (In MSSQL Server)

    MS Office Visio

    Hope you are not using EF up at the MVC layer, because it's nothing put pure trouble, particularly so if one has a complicated model.

    Monday, July 14, 2014 1:23 PM

All replies