linq2db / linq2db.EntityFrameworkCore

Bring power of Linq To DB to Entity Framework Core projects
MIT License
462 stars 38 forks source link

Inheritance TPH with HasDiscriminator doesn't work #60

Closed erwan-joly closed 1 year ago

erwan-joly commented 4 years ago

FYI : I noticed TPH doesn't work well with BulkCopy https://github.com/NosCoreIO/NosCore.Dao/blob/52480cab1ca7bbf3244663441603a4bcbf82b911/src/NosCore.Dao/Dao.cs#L145

the dbcontext https://github.com/NosCoreIO/NosCore.Dao/blob/master/test/NosCore.Dao.Tests/Database/NosCoreContext.cs

when running the tests i'm getting "NOT NULL constraint failed: CompositeTphBaseEntity.Discriminator"

i don't think TPH is widely used anyway but seems to be one of the current limitation of this library

zeocrash commented 3 years ago

I too am having this issue. It seems we may not be able to use Linq2Db because of this

sdanyliv commented 3 years ago

Will check what we can do here

zeocrash commented 3 years ago

The best workaround we think we found was to decorate our EF entities with L2Db attributes. We didn't try it in the end as we're firmly into crunch time on our dev stream. Also we felt that having essentially 2 sets of mappings (EFcore fluent and L2Db attributes). We'll definitely revisit L2DB at a later date though.

sdanyliv commented 3 years ago

@zeocrash. I have prepared fix in main library. If Discriminator field is not shadow property it will work. Probably will release new version this Thursday.

MaceWindu commented 1 year ago

Closing as fix was released long time ago (linq2db 3.4.4): https://github.com/linq2db/linq2db/pull/3204