Generate correct model from database containing pre-existing table per hierarchy inheritance
My very first Q. on StackOverflow:
I have a database originally generated using code first in Entity Framework 4.1. Another team and the DBA have asked that we move to database-first design for a number of good reasons. The database originally generated uses table per hierarchy inheritance in a variety of places. We attempted to generate a model (.edmx) based on the pre-existing database but the resulting model did not figure out the inheritance hierarchy (this may be impossible).
The only solution we currently may have seems extremely time intensive: it appears we开发者_C百科 will need to create each inherited entity, set to abstract the base classes/tables in the model, delete every association to base classes and recreate them to the inherited classes. Then validate the generated POCO's (generated via ADO.NET DbContext Generator template) against the original POCO's used when we were using the code-first approach.
This will be very time intensive given the amount of inheritance utilized in our model and prior to investing this time, we'd like to know if there is an easier way to get to a model that includes the inherited entities and appropriate associations / navigation properties.
Thanks! Matt
精彩评论