-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaffolding: Create default templates #28549
Conversation
test/EFCore.Design.Tests/Scaffolding/Internal/ModelCodeGeneratorTestBase.cs
Outdated
Show resolved
Hide resolved
@bricelam Is this ready for review? Looks like you just pushed changes. |
Yes, it can be reviewed. I expect a few more tweaks to the templates, but this could be merged to unblock others from working on scaffolding. They can always be fine-tuned in a later PR.
Just fixing the failing test. |
/// <param name="index">The index.</param> | ||
/// <param name="annotationCodeGenerator">The provider's annotation code generator.</param> | ||
/// <returns><see langword="true"/> if this index can be reperesented by a data annotation.</returns> | ||
public static bool HasDataAnnotation(this IIndex index, IAnnotationCodeGenerator annotationCodeGenerator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is HasDataAnnotation
the right name for "can be entirely reperesented by a data annotation?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, spelling, apparently. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to change it. To the user, these usually appear in predicates like Options.UseDataAnnotations && x.HasDataAnnotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HandledByDataAnnotations
might be a good alternative.
src/EFCore.Design/Scaffolding/Internal/CSharpDbContextGenerator.tt
Outdated
Show resolved
Hide resolved
@bricelam wonder how EF Core Power Tools can take advantage of all this, as it does not attempt to load the users project in any way. 🤥 |
@ErikEJ It should be able to work just fine without loading the user's assembly. If you just set |
@bricelam Wonderful! |
@ErikEJ I'm also working on a |
@bricelam Yes, I plan to include the default templates and Allow the user to drop them in the project just like with Handlebars templates today. And potentially offer more template sets over time for special use cases like UI modelbinding. |
This refactors our existing scaffolding code into T4 templates that we can both precompile to use as our default code generator and also ship somehow (probably `dotnet new`) as a starting point for users to start customizing. Part of dotnet#4038, part of dotnet#14545, fixes dotnet#25473, resolves dotnet#25546, resolves dotnet#25547, fixes dotnet#27087, part of dotnet#27588, fixes dotnet#28187
This refactors our existing scaffolding code into T4 templates that we can both precompile to use as our default code generator and also ship somehow (probably
dotnet new
) as a starting point for users to customize.Note, we're still reviewing and refining the templates. But the bulk of the changes are ready to go. I'll update this PR as work progresses, but we could also just do the fine-tuning in a later PR if we're ready to merge this one.
Part of #4038, part of #14545, resolves #25546, resolves #25547, fixes #27087, part of #27588, fixes #28187