mirror of
https://github.com/fergalmoran/EFCore.NamingConventions.git
synced 2025-12-22 09:38:21 +00:00
Fixup
See https://github.com/efcore/EFCore.NamingConventions/pull/47#pullrequestreview-549351916
This commit is contained in:
@@ -31,6 +31,11 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
if (entityType.BaseType is null)
|
if (entityType.BaseType is null)
|
||||||
{
|
{
|
||||||
entityTypeBuilder.ToTable(_namingNameRewriter.RewriteName(entityType.GetTableName()), entityType.GetSchema());
|
entityTypeBuilder.ToTable(_namingNameRewriter.RewriteName(entityType.GetTableName()), entityType.GetSchema());
|
||||||
|
|
||||||
|
if (entityType.GetViewNameConfigurationSource() == ConfigurationSource.Convention)
|
||||||
|
{
|
||||||
|
entityTypeBuilder.ToView(_namingNameRewriter.RewriteName(entityType.GetViewName()), entityType.GetViewSchema());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,16 +133,22 @@ namespace EFCore.NamingConventions.Internal
|
|||||||
.Where(p => p.Builder.CanSetColumnName(null)))
|
.Where(p => p.Builder.CanSetColumnName(null)))
|
||||||
{
|
{
|
||||||
var columnName = property.GetColumnBaseName();
|
var columnName = property.GetColumnBaseName();
|
||||||
var prefix = _namingNameRewriter.RewriteName(ownedEntityType.ShortName());
|
var prefix = ownedEntityType.ShortName() + '_';
|
||||||
if (!columnName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
|
||||||
|
if (columnName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
columnName = prefix + "_" + columnName;
|
columnName = columnName[prefix.Length..];
|
||||||
|
}
|
||||||
|
|
||||||
|
var rewrittenPrefix = _namingNameRewriter.RewriteName(prefix);
|
||||||
|
if (!columnName.StartsWith(rewrittenPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
columnName = rewrittenPrefix + columnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We should uniquify, but we don't know about all the entity types mapped
|
// TODO: We should uniquify, but we don't know about all the entity types mapped
|
||||||
// to this table. SharedTableConvention does its thing during model finalization,
|
// to this table. SharedTableConvention does its thing during model finalization,
|
||||||
// so it has the full list of entities and can uniquify.
|
// so it has the full list of entities and can uniquify.
|
||||||
// columnName = Uniquifier.Uniquify(columnName, properties, maxLength);
|
|
||||||
property.Builder.HasColumnName(columnName);
|
property.Builder.HasColumnName(columnName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user