从NotMapped类C首先实体框架4.1 $ C $派生实体类 [英] Derive Entity class from a NotMapped class in Entity Framework 4.1 Code First
本文介绍了从NotMapped类C首先实体框架4.1 $ C $派生实体类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从一个不属于模型中的基类派生我的两个实体类的。
I need to derive two of my Entity classes from a base class that does not belong to the model.
[NotMapped]
public abstract class BaseClass
{
[NotMapped]
public string SomeProperty { get; set; }
}
public partial class Derived1: BaseClass {}
public partial class Derived2: BaseClass {}
我已经试过标记的基类,其所有属性为 [NotMapped]
但上下文初始化抛出一个错误,说我的两个派生的实体类未映射。
I have tried marking the base class and all its properties as [NotMapped]
but the context initializer throw an error saying that both my derived entity classes are not mapped.
推荐答案
想通了。的[NotMapped]属性不应该被施加到基类,但只有其属性。
Figured it out. The [NotMapped] attribute should not have been applied to the base class, but only its properties.
这篇关于从NotMapped类C首先实体框架4.1 $ C $派生实体类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文