Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑到这个数据库:
这是 EF 生成的:
我认为 HeroesItem 类,没用,应该在 Hero 类上有一个导航属性 Items,在 Item 类上有一个导航属性 Heroes。
我看到这可以通过代码轻松完成,但是如何首先使用数据库完成呢?
仅当您的HeroesItems表不包含Id列,而是使用IdHeroandIdItem作为复合主键时,才可以这样做。将任何其他列添加到联结表后,您必须将其映射为实体才能控制该列。
HeroesItems
Id
IdHero
IdItem