Skip to content

Commit

Permalink
Refactor ModelBuilderExtensions to update table names
Browse files Browse the repository at this point in the history
The method "ConfigureOwnedTypeColumnNames" has been renamed and refactored to "ConfigureOwnedTypeTableName". The updated method now changes the
  • Loading branch information
Gary Woodfine committed Apr 11, 2024
1 parent 5af041b commit a1d75f2
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/Extensions/ModelBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@ namespace Threenine.Database.Extensions;

public static class ModelBuilderExtensions
{
public static void ConfigureOwnedTypeColumnNames(this ModelBuilder modelBuilder)
public static void ConfigureOwnedTypeTableName(this ModelBuilder modelBuilder)
{
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
if (!entityType.IsOwned()) continue;

var ownership = entityType.FindOwnership();

if (ownership is null) continue;

var properties = entityType.GetProperties().Where(x => !x.IsShadowProperty());

foreach (var property in properties)
{
var tableName = entityType.GetTableName();
entityType.SetTableName(tableName.ToSnakeCase());
}
var tableName = entityType.GetTableName();
entityType.SetTableName(tableName.ToSnakeCase());

}
}
}

0 comments on commit a1d75f2

Please sign in to comment.