I have following code.
public class Person
{
public string LastName { get; set; }
}
public class Employee : Person
{
}
With configuration
Map(p => p.MapInheritedProperties());
Property(p => p.LastName).HasMaxLength(100).IsRequired();
And want to change it to
public class Person
{
public virtual string LastName {get; set;}
}
public class Employee : Person
{
public override string LastName
{
get { return base.LastName; }
set
{
//add validation here or throw exception
base.LastName = value;
}
}
}
If I run the application it says that the model has been changed. Fine, I add a DB Migration, but it errors:
The property 'LastName' is not a declared property on type 'Employee'.
Verify that the property has not been explicitly excluded from the model by using the
Ignore method or NotMappedAttribute data annotation. Make sure that it is a valid primitive property.
What kind of mapping do I need to add for this to work? I use EF 4.3 with Migrations.
Thanks for any hints.