简体   繁体   English

ef核心-如何使一个类映射的多个变体到同一张表

[英]ef core - how to make multiple variations of a class map to the same table

I have 5 satellite assemblies with their own db contexts. 我有5个带有各自数据库上下文的附属程序集。 I created a 6th the assembly just for code first migration. 我创建了第6个程序集,仅用于代码优先迁移。 The idea was to add the satellite assemblies as references then create migration for all models. 想法是添加附属程序集作为参考,然后为所有模型创建移植。 The quirk with this setup is that some of the satellite assemblies have same classes but with more or less properties(depending on whether they make sense in their respective context ). 这种设置的怪异之处在于,某些附属程序集具有相同的类,但具有或多或少的属性(取决于它们是否在各自的上下文中有意义)。

When I create a migration I get: Cannot use table 'dbo.TableA' for entity type 'PartialClassA' since it is being used for entity type 'ClassA' and there is no relationship between their primary keys. 创建迁移时,我得到: Cannot use table 'dbo.TableA' for entity type 'PartialClassA' since it is being used for entity type 'ClassA' and there is no relationship between their primary keys.

I hope what I am trying to do make sense, my question is how do we make this work with code first? 我希望我想做的有意义,我的问题是我们如何首先使用代码进行这项工作?

对于任何有兴趣的人,这是ef core github论坛的回复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM