Search code examples
entity-frameworkmultiple-databases

How to work with multiple databases in entity-framework?


I'm working with entity-framework and MVC and i have two databases in the same server.

I just want to do a select in a table in the "database1" then do another select in a table in the "database2" in the same code but i don't know how to configure two diferent databases in my project.

Can someone show me how to configure it to do this? and how to use it in the code?


Solution

  • You have to setup your connection in your database initilizer. In EF6 you have a good support for multiple databases.

    Check this link: Using entity framework on multiple databases