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
If the casing of a SQL column name does not match the default property name returned by IEntityType.GetProperties(), scaffolding generates a HasColumnName call for both the original name returned from IEntityType.GetProperties(), as well as the actual database column name.
Expected behavior
Generate a single HasColumnName call with the correct SQL column name.
To Reproduce
Create and scaffold a database with SQL table (note that the identity column ends in "ID", all caps):
CREATE TABLE [dbo].[TestTable](
[TestTableID] [int] IDENTITY(1,1) NOT NULL,
[SomeOtherColumn] [nvarchar](10) NULL
) ON [PRIMARY]
In this case, IEntityType.GetProperties() will return a property called TestTableId ('d' is lower-case).
Using the following design time options:
public void ConfigureDesignTimeServices(IServiceCollection services)
{
services.AddHandlebarsScaffolding();
// Sample property renaming from EntityFrameworkCore.Scaffolding.Handlebars documentation
services.AddHandlebarsTransformers2(
// Rename EntityID to Id
propertyTransformer: (e, p) =>
$"{e.Name}Id" == p.PropertyName
? new EntityPropertyInfo(p.PropertyType, "ID", false)
: new EntityPropertyInfo(p.PropertyType, p.PropertyName, p.PropertyIsNullable));
}
Produces:
entity.Property(e => e.ID) // Correct new property name
.HasColumnName("TestTableId") // Incorrect: Default property name from EFCore.IEntityType.GetProperties
.ValueGeneratedOnAdd()
.HasColumnName("TestTableID"); // Correct SQL column name
The text was updated successfully, but these errors were encountered:
Describe the bug
If the casing of a SQL column name does not match the default property name returned by IEntityType.GetProperties(), scaffolding generates a
HasColumnName
call for both the original name returned fromIEntityType.GetProperties()
, as well as the actual database column name.Expected behavior
Generate a single HasColumnName call with the correct SQL column name.
To Reproduce
Create and scaffold a database with SQL table (note that the identity column ends in "ID", all caps):
In this case, IEntityType.GetProperties() will return a property called TestTableId ('d' is lower-case).
Using the following design time options:
Produces:
The text was updated successfully, but these errors were encountered: