You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
With setting of handlebar transformer:
public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
{
serviceCollection.AddHandlebarsScaffolding();
serviceCollection.AddHandlebarsTransformers(
entityFileNameTransformer: x => x + "DAO",
entityTypeNameTransformer: x => x + "DAO",
constructorTransformer: x =>
{
x.PropertyType += "DAO";
return x;
},
navPropertyTransformer: x =>
{
x.PropertyType += "DAO";
return x;
});
serviceCollection.AddSingleton<IPluralizer, Pluralizer>();
}
DbContext will be generated by reverse engine and used CodeTemplates in Handlebars.
Class of Action and Permission after generated like this:
public partial class ActionDAO
{
public ActionDAO()
{
Pages = new HashSet<PageDAO>();
Permissions = new HashSet<PermissionDAO>();
}
public long Id { get; set; }
public string Name { get; set; } = null!;
public long MenuId { get; set; }
public bool IsDeleted { get; set; }
public virtual MenuDAO Menu { get; set; } = null!;
public virtual ICollection<PageDAO> Pages { get; set; }
public virtual ICollection<PermissionDAO> Permissions { get; set; }
}
public partial class PageDAO
{
public PageDAO()
{
Actions = new HashSet<ActionDAO>();
}
public long Id { get; set; }
public string Name { get; set; } = null!;
public string Path { get; set; } = null!;
public long MenuId { get; set; }
public bool IsDeleted { get; set; }
public virtual ICollection<ActionDAO> Actions { get; set; }
}
The errors appear in OnModelCreating(ModelBuilder modelBuilder), in sections of mapping table
"entity.HasMany(d => d.PagesDAO)" should be "entity.HasMany(d => d.Pages)"
and ".WithMany(p => p.ActionsDAO)" should be ".WithMany(p => p.Actions)" Expected behavior
Template should generate
I have the same issue when generating the DbContext. Had the look at the code generating the many to many relationships and found the issue.
In the HbsCSharpDbContextGenerator.GenerateManyToMany the property names get transformed with EntityTypeTransformationService.TransformTypeEntityName. But in this case the resolver for entitytypes shouldn't be used, but instead the resolver for a navigation property should be used (like it does in generating the one to many relationships).
Would be nice if this could be fixed so the correct code gets generated
Describe the bug
With setting of handlebar transformer:
DbContext will be generated by reverse engine and used CodeTemplates in Handlebars.
Class of Action and Permission after generated like this:
The errors appear in OnModelCreating(ModelBuilder modelBuilder), in sections of mapping table
"entity.HasMany(d => d.PagesDAO)" should be "entity.HasMany(d => d.Pages)"
and ".WithMany(p => p.ActionsDAO)" should be ".WithMany(p => p.Actions)"
Expected behavior
Template should generate
The text was updated successfully, but these errors were encountered: