Reputation: 1715
I have below structure of classes:
SecurityLayer.Domain dll
SecurityLayer.Data dll
Now I build another product which uses two packages above. And I have below structure
The problem is when I use Add-Migration on MyProduct.Data project, EF generates a migration to create ALL entities from both MyProduct.Domain and SecurityLayer.Domain
I know that EF6 support multiple DbContext in a single database, but it does not work for me. Can we do something to let EF avoid entities in SecurityLayer.Domain? Any advice is much appreciate. Tks a lot!
Upvotes: 1
Views: 309
Reputation: 119156
The easiest way would be to create your initial migration and remove the bits from it that are not relevant. Subsequent migrations will not pick up the existing tables due to the way EF works.
Migrations actually store the state of the database in a table called __MigrationHistory
. One of those columns contains a zipped up EDMX file. You can extract the content as a blob, save it as a .zip
file and see for yourself. Each migration uses that to determine what has changed since the previous migration.
Upvotes: 1