Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql Table Inheritance in entity framework

I wonder if it is possible to do postgres table inheritance in entity framework 7 - instead of the addition of columns do a "real" postgres with base table and table that inherit base table?

If so, how do I configure that?

Cheers, Mario

like image 857
Mario Toffia Avatar asked Jun 17 '26 11:06

Mario Toffia


1 Answers

This is definitely not supported. In theory you could create your database schema yourself with inheritance (so outside EFCore) and then mapping CLR entities to that, without EFCore knowing anything about the table inheritance. However, if the CLR classes themselves inherit from one another (as they should in general), that would likely trigger EFCore's own inheritance feature, which will mess everything up. If there's some way to tell EFCore to disregard the CLR inheritance you might be able to get away with it.

As for a more complete solution where EFCore is actually aware of PostgreSQL inheritance, that would probably be a pretty big task, which would probably involve changes in EFCore itself (and not just the Npgsql provider).

Can you please open an issue? I definitely won't have any time to work on this anytime soon but it's good to have it in the list.

like image 173
Shay Rojansky Avatar answered Jun 19 '26 13:06

Shay Rojansky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!