dotnet / dotnet/efcore

Scaffolding: Make it easier to generate by-convention configuration

Open
#28,641 0 comments 0 reactions 0 assignees View on GitHub
area-scaffolding
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Today, the `GetFluentApiCalls` and `GetDataAnnotations` extensions used by the templates automatically filter out configurations that will be handled by conventions. It would be nice if the user could still choose to include these in the generated code.

I imagine that we'd add a property like `IsHandledByConventions` to the returned objects. And just filter them back out in the templates.

Then if users want, for example, to always include validation attributes (#9580), the templates could include code like this.

```c#
var dataAnnotations = property.GetDataAnnotations(annotationCodeGenerator)
.Where(a => !a.IsHandledByConventions || a.Type.IsSubclassOf(typeof(ValidationAttribute));
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.