msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
119 stars 21 forks source link

TablePerType Inheritance and New HasNoKey() #55

Closed ab-tools closed 1 year ago

ab-tools commented 1 year ago

This issue seems similar to what is reported here, but not sure if it is really the same problem.

We have Inheritance Strategy set to TablePerType and 2 tables inheriting from one base table. All was working fine with EFDesigner version 4.0.0.6.

Now that we updated our project to EFCore 7, we also updated EFDesigner version to 4.2.1.3.

Without doing any other changes to the model, just regenerating the code, it adds now a .HasNoKey() to the 2 inheriting tables resulting in this run-time error: System.InvalidOperationException: 'The key {'Id'} cannot be removed from the entity type 'SubTableName' because it is defined on the entity type 'BaseTableName'.'

If I manually remove the 2 .HasNoKey() from the generated code everything is working fine.