Fluent mapping of base class columns

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
jszalay
Posts: 5
Joined: Thu 10 Sep 2015 18:53

Fluent mapping of base class columns

Post by jszalay » 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?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Fluent mapping of base class columns

Post by MariiaI » Tue 15 Sep 2015 06:08

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.

jszalay
Posts: 5
Joined: Thu 10 Sep 2015 18:53

Re: Fluent mapping of base class columns

Post by jszalay » Fri 18 Sep 2015 15:26

Thanks for the links. I missed the inheritance part of the documentation. TPH should provide and adequate solution for my problem.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Fluent mapping of base class columns

Post by MariiaI » Mon 21 Sep 2015 06:15

If you encounter any issues with this, feel free to contact us.

Post Reply