Page 1 of 1

Fluent mapping of base class columns

Posted: Thu 10 Sep 2015 19:10
by jszalay
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?

Re: Fluent mapping of base class columns

Posted: Tue 15 Sep 2015 06:08
by MariiaI
Sorry for the delay. Please refer to these articles:
https://www.devart.com/linqconnect/docs ... pping.html
https://www.devart.com/linqconnect/docs/?FluentTPT.html
https://www.devart.com/linqconnect/docs/?FluentTPH.html

If the provided information doesn't help to solve the issue, please create a small test project with which this error could be reproduced and send it us.
This will significantly speed up the process of determining the cause of the error and finding the solution for you.

Looking forward to your reply.

Re: Fluent mapping of base class columns

Posted: Fri 18 Sep 2015 15:26
by jszalay
Thanks for the links. I missed the inheritance part of the documentation. TPH should provide and adequate solution for my problem.

Re: Fluent mapping of base class columns

Posted: Mon 21 Sep 2015 06:15
by MariiaI
If you encounter any issues with this, feel free to contact us.