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
{{ message }}
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
When you have model that contains one base entity and 2 derived entities (example: WorkItem as a base entity and RemediationTicket and CAPA as derived entities) and then you try to set relation one to many between derived entities, designer generates he following code in dbContext OnModelCreating method:
HasForeignKey() crashes at runtime since it must have FK name. As I can see, the issue is probably because FK name is constructed by the designer by concatenating relation name and Id field, but in this case Id field does not exist in derived entity but in the base one. So, in this case method: .HasForeignKey("RemediationTicket_Id") should be generated, but obviously designer does not know to do that.
I tried various workarounds but didn't find the appropriate one. I can add key name manually, but designer will overwrite it on every change. Can this bug be fixed?
The text was updated successfully, but these errors were encountered:
When you have model that contains one base entity and 2 derived entities (example: WorkItem as a base entity and RemediationTicket and CAPA as derived entities) and then you try to set relation one to many between derived entities, designer generates he following code in dbContext OnModelCreating method:
modelBuilder.Entity<global::Novolyze.Ticketing.Services.Model.Capa>() .HasOne(x => x.RemediationTicket) .WithMany(x => x.Capas) .HasForeignKey();
HasForeignKey() crashes at runtime since it must have FK name. As I can see, the issue is probably because FK name is constructed by the designer by concatenating relation name and Id field, but in this case Id field does not exist in derived entity but in the base one. So, in this case method: .HasForeignKey("RemediationTicket_Id") should be generated, but obviously designer does not know to do that.
I tried various workarounds but didn't find the appropriate one. I can add key name manually, but designer will overwrite it on every change. Can this bug be fixed?
The text was updated successfully, but these errors were encountered: