Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity framework 4 and multiple database

Something changes or it still not support this? For example join database1.dbo.Users and database2.dbo.Addresses

like image 367
dotneter Avatar asked Apr 17 '10 20:04

dotneter


People also ask

Can we use multiple database in Entity Framework?

Entity Framework : A Comprehensive Course Multiple DbContext was first introduced in Entity Framework 6.0. Multiple context classes may belong to a single database or two different databases.

Can we have multiple DbContext in Entity Framework?

In code first, you can have multiple DBContext and just one database. You just have to specify the connection string in the constructor. Yes you can, but how can you query from different entities from different db contexts?


1 Answers

I actually did find a way to make an EF model span multiple databases if your database supports Synonyms. Basically you setup Synonyms to Database2 on Database1, create separate edmx models for each, then merge the XML

I posted the exact steps to make an edmx file span multiple databases here if you're interested, along with a script to do the merge for you whenever something changes.

like image 136
Rachel Avatar answered Oct 02 '22 22:10

Rachel