You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've some issues defining these relationships between my entities. A CarTemplate is base class with common properties. CoupeTemplate and SedanTemplate are 2 template of coupe and sedan cars with different attributes. A CarTemplate can have more Car
publicclassCarTemplate{publiclongId{get;set;}publicstringCarType{get;set;}//Discriminator required from TPHpublicList<Car> Cars {get;set;}}publicclassCoupeTemplate:CarTemplate{publicstringCoupeAttribute1{get;set;}publicstringCoupeAttribute2{get;set;}}publicclassSedanTemplate:CarTemplate{publicstringAttributeSedan1{get;set;}publicstringAttributeSedan2{get;set;}}publicclassCar{publiclongId{get;set;}publiclongAttribute1Car{get;set;}}publicclassCoupe:Car{publicstringAttribute1Coupe{get;set;}publicstringAttribute2Coupe{get;set;}}publicclassSedan:Car{publicstringAttribute1Sedan{get;set;}publicstringAttribute2Sedan{get;set;}}
Now I would like to use the same CarType attribute on CarTemplate to determine the type of a "Car". So what I would do with Fluent API is something like
I would like to reuse the Discriminator of the other related entity instead of creating a new one which introduce data redundancy(e.g. Coupe value would be present in the CarTemplate table and also in the Car table)
Do you think it is possible to do something like this with EF Core? Any suggestion on the modelling is really appreciated!
Further technical details
EF Core version: 2.2
Database Provider: SQL Server
Operating system:
IDE: Visual Studio 2017 15.9.6
The text was updated successfully, but these errors were encountered:
@elciopa There are some inconsistencies/missing pieces in the code above, but I think you mean that if each row in the Cars table has a FK to a row in the CarTemplates table, then that could be used to determine the type of Car in the Cars table. If so, this isn't currently supported, but could possibly be covered by #10140.
@elciopa There are some inconsistencies/missing pieces in the code above, but I think you mean that if each row in the Cars table has a FK to a row in the CarTemplates table, then that could be used to determine the type of Car in the Cars table. If so, this isn't currently supported, but could possibly be covered by #10140.
Yes that's what I meant. Thanks a lot for the tip.
I've some issues defining these relationships between my entities. A CarTemplate is base class with common properties. CoupeTemplate and SedanTemplate are 2 template of coupe and sedan cars with different attributes. A CarTemplate can have more Car
Here the modeling for the TPH on CarTemplate,
Now I would like to use the same CarType attribute on CarTemplate to determine the type of a "Car". So what I would do with Fluent API is something like
I would like to reuse the Discriminator of the other related entity instead of creating a new one which introduce data redundancy(e.g. Coupe value would be present in the CarTemplate table and also in the Car table)
Do you think it is possible to do something like this with EF Core? Any suggestion on the modelling is really appreciated!
Further technical details
EF Core version: 2.2
Database Provider: SQL Server
Operating system:
IDE: Visual Studio 2017 15.9.6
The text was updated successfully, but these errors were encountered: