Skip to content

Commit 587c981

Browse files
Add more comments to document database changes from PascalCase to snake_case.
1 parent 0a744e8 commit 587c981

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

api/Models/DefaultDbContext.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,37 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
1919
{
2020
base.OnModelCreating(modelBuilder);
2121

22-
// Replace table names
2322
foreach(var entity in modelBuilder.Model.GetEntityTypes())
2423
{
25-
24+
// Remove 'AspNet' prefix and convert table name from PascalCase to snake_case. E.g. AspNetRoleClaims -> role_claims
2625
entity.Relational().TableName = entity.Relational().TableName.Replace("AspNet", "").ToSnakeCase();
2726

28-
// Replace column names
27+
// Convert column names from PascalCase to snake_case.
2928
foreach(var property in entity.GetProperties())
3029
{
3130
property.Relational().ColumnName = property.Name.ToSnakeCase();
3231
}
33-
32+
33+
// Convert primary key names from PascalCase to snake_case. E.g. PK_users -> pk_users
3434
foreach(var key in entity.GetKeys())
3535
{
3636
key.Relational().Name = key.Relational().Name.ToSnakeCase();
3737
}
3838

39+
// Convert foreign key names from PascalCase to snake_case.
3940
foreach(var key in entity.GetForeignKeys())
4041
{
4142
key.Relational().Name = key.Relational().Name.ToSnakeCase();
4243
}
43-
44+
45+
// Convert index names from PascalCase to snake_case.
4446
foreach(var index in entity.GetIndexes())
4547
{
4648
index.Relational().Name = index.Relational().Name.ToSnakeCase();
4749
}
4850
}
51+
4952
}
53+
5054
}
5155
}

0 commit comments

Comments
 (0)