Description
Include your code
The combination of inheritance mapping and the use of Complex types, gives strange behavior in TPC mapping.
I tried TPH and TPT (line 118), and there everything works as expected.
What I see is:
- model seems ok, but the creation of tables is not ok -> columns of the complex type are missing
- If I run polymorphic queries I get an exception in TPC, works fine in TPH and TPT
See https://github.com/dvdwouwe/danny-playground-ef/tree/main for reproducing the behavior we see.
Commit SHA: d194a6f9a7a783a5579a03ed9ceb764955e0dd2d
Include provider and version information
EF Core version: 8.0.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0.403
Operating system: Windows 11
IDE: Rider
Activity
cincuranet commentedon Oct 31, 2024
Not
Microsoft.EntityFrameworkCore.SqlServer
specific, repros onMicrosoft.EntityFrameworkCore.Sqlite
as well. Repros on9.0.0-rc.2.24474.1
.Smaller repro
The table created is only:
Also, query throws exception:
maumar commentedon Nov 7, 2024
When trying to bind complex property we are looking for table mapping so that we know which table/columns to bind. However the table mapping is missing here - We build those as part of RelationalModel.Create. Here, the complex type is defined on the abstract base type, and we skip those when creating table mappings. When processing the derived type we only look at declared complex types and so we miss the type defined on the base. As a result the complex property ends up with no table mapping
dvdwouwe commentedon Nov 29, 2024
Hi,
Actually this is blocking us. We have a rather huge (potential) project by a large company, but we need an example that is production ready. The expectations for this in August 2025. If it is successful, it will be one of our biggest projects ever.
TPH mapping is not very suitable for this:
TPT is too slow, because of the huge number of abstract subclasses.
Create table mappings for complex types in TPC
AndriySvyryd commentedon Dec 11, 2024
@dvdwouwe There are two workarounds that you can consider using for now:
19 remaining items