Derive Entity class from a NotMapped class in Entity Framework 4.1 Code First

.net, c#, ef-code-first, entity-framework

Solution

Figured it out. The [NotMapped] attribute should not have been applied to the base class, but only its properties.

Problem

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 {} ``` 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.

Original source