TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

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

Add .ToTable and .HasColumnName methods when using Transforms #194

Closed gpender closed 2 years ago

gpender commented 2 years ago

When using Transform mappings, and UseDataAnnotations=false, provide .ToTable and .HasColumnName methods in the generated context when table and column names are different to the entity and property names.

When using Transform mappings, and UseDataAnnotations=true, use ColumnAttribute in generated entities and do not use .ToTable and .HasColumnName methods in the context.

Closes #188.

tonysneed commented 2 years ago

@gpender The PR looks good overall. One issue I found is that .HasKey need to be appended to .ToTable because renaming the PK can result in a deviation from the standard key naming convention.

I'll work on resolving this issue.