I'd like to combine multiple databases into one Entity Framework "object model". I do not need to change databases dynamically at runtime. This is a static configuration issue. It should look like this:
And I should be able to say:
new XyzContext().Entities1
new XyzContext().Entities2
How can I configure Entity Framework to take note of my multiple databases?
I do not want to create views or synonyms. This question is about an EF only solution. I'm using the latest EF version and can switch to any version.
There is no way to do it directly with Entity Framework, the context is linked to a Database and you can't access tables directly outside that Database. I don't know your situation, but if I were you first of all I would try to move that tables to my Database.
If this is not possible one workaround to do it's just create views to your external table. But be careful populating views, remember every time that you modify the schema of your external table, to recreate the view, and it's something that is easy break.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.