从包含每个层次结构继承的预先存在的表的数据库生成正确的模型
我在 StackOverflow 上的第一个问题:
我有一个最初在 Entity Framework 4.1 中使用代码优先生成的数据库。另一个团队和 DBA 出于许多充分的理由要求我们转向数据库优先设计。最初生成的数据库在多个地方使用每个层次结构表继承。我们尝试根据预先存在的数据库生成模型(.edmx),但生成的模型没有弄清楚继承层次结构(这可能是不可能的)。
我们当前可能拥有的唯一解决方案似乎非常耗时:看来我们需要创建每个继承的实体,设置为抽象模型中的基类/表,删除与基类的每个关联并将它们重新创建为继承的类。然后根据我们使用代码优先方法时使用的原始 POCO 验证生成的 POCO(通过 ADO.NET DbContext Generator 模板生成)。
考虑到我们的模型中使用的继承量,这将非常耗时,在投入这一次之前,我们想知道是否有更简单的方法来获取包含继承实体和适当关联/导航属性的模型。
谢谢! 马特
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 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论