TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

Scaffold EF Core models using Handlebars templates.
MIT License
208 stars 53 forks source link

HasKey Reference Left Out with Non-Conventional Key Property #203

Closed davidhendrickmb closed 2 years ago

davidhendrickmb commented 2 years ago

Hi there,

This is in relation to the issue here which Erik has mentioned is a problem with this package. The HasKey reference is being left out when I use Handlebars templates with EF Core 6. Would you know of a fix for this?https://github.com/ErikEJ/EFCorePowerTools/issues/1250

Thanks, David

ErikEJ commented 2 years ago

Or maybe the Key attribute?

tonysneed commented 2 years ago

Thanks for reporting the bug. I'll work on fixing it.

davidhendrickmb commented 2 years ago

Thank you :) If you happen to find a temporary workaround please let me know as I'm trying to test out Net 6 upgrade.

tonysneed commented 2 years ago

@davidhendrickmb I am looking at this now. It has to do with the PK not following EF Core naming conventions. I will fix the bug, but if you wish to have a workaround, simply make sure your PK entity property follows the standard EF Core naming convention for key fields. In other words, entitynameId. In your case this would be: AccompanimentTypeId

ErikEJ commented 2 years ago

Potential duplicate: https://github.com/ErikEJ/EFCorePowerTools/issues/1256

RaulFunezp commented 2 years ago

I have exactly the same problem when using HandleBars in ErikEJ/EfCorePowerTools. The name of my HasKey not generated is like this: AeDeCtaCB.

I hope that when Tony solves that bug, it will solve my case too. Thank you

tonysneed commented 2 years ago

@ErikEJ @davidhendrickmb @RaulFunezp Fixed with Handlebars v6.0.3.

davidhendrickmb commented 2 years ago

Thanks Tony, much appreciated!