【发布时间】:2017-01-27 22:36:58
【问题描述】:
我使用的是 EF6 代码优先。假设以下场景。我们有这个类:
class Foo
{
public int Id { get; set; }
public A AProperty { get; set; }
public B BProperty { get; set; }
}
有没有办法通过使用 Data Annotations 或 Entity Framework Fluent Api 而无需重新设计整个模型来确保任何 Foo 实体必须具有至少一个与 null 不同的属性,但不能同时具有两者?
这类似于question 中的回答,但使用 EF。
【问题讨论】:
标签: c# entity-framework ef-code-first entity-framework-6 ef-fluent-api