EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

GetWithMethod on OneToOne Relationship asserts table name as entity name

Open kurt-o-matic opened this issue 5 years ago • 0 comments

Hi, in my use-case I am using the "Entity" suffix for entity names (EFCore 3, v3.1.3). When generating foreign keys with a one-to-one relationship, the .HasForeignKey<T>() method is written out with the unaltered table name as T, which obviously won't compile in my case.

builder.HasOne(a => a.AppTransaction)
       .WithOne(b => b.Issue)
       .HasForeignKey<Issue>(c => c.AppTransactionId)...

vs

builder.HasOne(a => a.AppTransaction)
       .WithOne(b => b.Issue)
       .HasForeignKey<IssueEntity>(c => c.AppTransactionId)...

This can be seen in line 278 of GeneratorEfCore.cs, where the fkTableNameHumanCase parameter of GetWithMethod() is used for the entity type name.

Thanks so much for your attention to this issue.

kurt-o-matic avatar May 22 '20 16:05 kurt-o-matic