Fluent mapping of base class columns
Posted: Thu 10 Sep 2015 19:10
I've got a class that is derived from a simple base class.
public class A
{
public string Id { get; set; }
public long Value { get; set; }
}
public class B: A {}
I build the mapping for B like this
...
builder.Entity<B>().Property(p => p.Id)....
builder.Entity<B>().Property(p => p.Value)....
...
I get the following error when I call DataContext.CreateDatabase(false, true)
"Table 'B' has no columns."
The same steps work if I replace 'B' with 'A' in the table definition and in the fluent-specific code.
Question: How can I map the public properties of a base class as columns?
public class A
{
public string Id { get; set; }
public long Value { get; set; }
}
public class B: A {}
I build the mapping for B like this
...
builder.Entity<B>().Property(p => p.Id)....
builder.Entity<B>().Property(p => p.Value)....
...
I get the following error when I call DataContext.CreateDatabase(false, true)
"Table 'B' has no columns."
The same steps work if I replace 'B' with 'A' in the table definition and in the fluent-specific code.
Question: How can I map the public properties of a base class as columns?