TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

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

[Question] How to have an index that could be incremented by hand from inside the main template and partials #139

Closed omatrot closed 3 years ago

omatrot commented 3 years ago

I would like to add a Newtonsoft.Json attribute [JsonProperty(Order = X)] in the c# generated code. X should start at one and would be incremented for each properties and each navigation properties (thus in each corresponding partial in my case). Is it something that we could implement? Any guidance to allow me to start with something? Thanks in advance.

tonysneed commented 3 years ago

I think the best way to do this would be to extend HbsCSharpEntityTypeGenerator and override GenerateProperties. Then you can add property-order to the template data and use it in your hbs file.

For an example of this approach see here.

omatrot commented 3 years ago

Thanks for that.