问题
What options are available to correctly map the following using Entity Framework:
Database 1 tables: Foo, Foo_Assets, Assets
Database 2 tables: Bar, Bar_Assets, Assets
I have considered mapping Bar, Bar_Assets, Assets as SQL views, or using a different db context when loading these tables from Database 2.
The challenge is that although Foo, Bar and their _Assets tables can be treated independently, both databases have an Assets table. How can these tables be correctly mapped to the Asset entity?
回答1:
Since you have 2 databases, you will have 2 edmx files. Just having a different name in the edmx for Assets table will work. This way you can ensure that there are no clashes.
来源:https://stackoverflow.com/questions/10248601/entity-framework-map-same-table-that-exists-in-two-databases