EntityFrameworkCore.Generator
EntityFrameworkCore.Generator copied to clipboard
[Feature] Add 'Generate' option for the data-mapping
In our company, we use your generator for many years now with many developers. Over the years, we added some features so it works better with our solutions. As a sign of appreciation, I want to suggest some features because I think it will help some other developers as well.
Feature description: Add a 'generate' option for the mapping classes which indicates if the mappings should be generated or not.
YAML usage:
data:
mapping:
generate: true
Please review the feature request and evaluate if you think this is an addition to your repo. (pull request will be added)
Thanks
Why would you want to turn this off? The mapping is mostly required. Are you using attribute based mapping?
I can assume a dev generates an initial version of the entities and de mappings, afterwards makes changes to the mapping and wants to prevent these changes to be overridden when regenerating.
you can make changes anywhere outside the region, and it will be saved.
public void Configure(Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<Core.Data.Entities.Company> builder)
{
#region Generated Configure
// table
builder.ToTable("Company", "dbo");
// key
builder.HasKey(t => t.Id);
// properties
builder.Property(t => t.Id)
.IsRequired()
.HasColumnName("Id")
.HasColumnType("int")
.ValueGeneratedOnAdd();
builder.Property(t => t.Name)
.IsRequired()
.HasColumnName("Name")
.HasColumnType("nvarchar(100)")
.HasMaxLength(100);
#endregion
// Safe to make changes here
}
@pwelter34 if changes outside the generated region override the config above, it is indeed a solution. If you think there is no other valid scenario to ignore the mappings, you can close the issue.