实体框架4隐藏底层解析器表时,从数据库生成模型 [英] Entity Framework 4 Hiding Underlying Resolver Tables when model is generated from database

查看:202
本文介绍了实体框架4隐藏底层解析器表时,从数据库生成模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建一个实体框架模型从头开始,可以指定一个许多模型中的许多关系。

When creating an entity framework model from scratch it is possible to specify a Many to Many relationship in the model.

例如使用实体* ----- *实体2

e.g Entity1 * ----- * Entity2

当随后从该生成的数据库,解析表将自动在两个实体之间产生,这是隐藏在code模型,允许通过属性直接访问每一个实体。

When a database is then generated from this, a resolver table is then created automatically between the two entities, this is hidden in the code model, allowing direct access to each of the entities via properties.

例如。使用实体---- * ResolverEntity * -----实体2

e.g. Entity1 ----* ResolverEntity *----- Entity2

我的问题是,当从一个现有的数据库,其中包含解析表,是否有可能产生相同的影响,所以解析器表不出现在生成的对象模型生成的模型?

My question is, when a model is generated from an existing database, which contains resolver tables, is it possible to create the same effect so the resolver tables do not appear in the generated object model?

当我试图这样,实体框架出现在模型与藏匿其中的对象模型中没有明显的方式分解表中创建的实体。

When I have attempted this, the entity framework appears to create entities in the model for the resolver tables with no obvious way of hiding them in the object model.

感谢。

推荐答案

是的,只要你在调用解析表只包含两列,FKS要使用实体和实体2,而这两列形成复合PK。在此情况下,EF GUI设计将识别该图案,并产生一个多对多的关系。如果你的数据库架构不符合这些限制,你必须手动编辑EDMX。

Yes, provided that what you're calling the "resolver table" contains only two columns, FKs to Entity1 and Entity2, and that those two columns form a compound PK. In this case, the EF GUI designer will recognize the pattern and generate a many to many relationship. If your DB schema doesn't fit these constraints, you'd have to edit the EDMX by hand.

这篇关于实体框架4隐藏底层解析器表时,从数据库生成模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆