TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

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

T4 Templates vs Scaffolding.Handlebars #231

Open mtayyabviz opened 10 months ago

mtayyabviz commented 10 months ago

I have just came across to this repository and also to T4 Templates.

My question is when you do scaffolding with --force your model codes and dbcontext classes gets overwritten. If you have tables around 100, should I have to create partial class for every single model? Please correct me I am wrong

Also, how effective is this as compared to T4 Templates that recommend you don't need to create partial classes but templates to handle your scaffolding.

Thank you!

ErikEJ commented 10 months ago

T4 and handlebars serve the same purpose of letting you control the output from scaffolding. You use JavaScript to customize the Handlebars template, and C# to customize the T4 template. T4 templates only work with EF Core 7 or newer.

mtayyabviz commented 10 months ago

I don't know but I found handlebar syntax more friendly, so I will prefer to use this rather than T4 :+1:

tonysneed commented 10 months ago

I would recommend only a partial class for the DbContext. For entities it would be better to use a base class for common functionality.

The other difference between Handlebars and T4 is that the former emphasizes a separation between the template and code. But you can accomplish the same result with either.

tony-asu commented 1 month ago

Is there a way to add configuration classes? Like when adding EntityTypeConfiguration.t4