File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -19,33 +19,37 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
19
19
{
20
20
base . OnModelCreating ( modelBuilder ) ;
21
21
22
- // Replace table names
23
22
foreach ( var entity in modelBuilder . Model . GetEntityTypes ( ) )
24
23
{
25
-
24
+ // Remove 'AspNet' prefix and convert table name from PascalCase to snake_case. E.g. AspNetRoleClaims -> role_claims
26
25
entity . Relational ( ) . TableName = entity . Relational ( ) . TableName . Replace ( "AspNet" , "" ) . ToSnakeCase ( ) ;
27
26
28
- // Replace column names
27
+ // Convert column names from PascalCase to snake_case.
29
28
foreach ( var property in entity . GetProperties ( ) )
30
29
{
31
30
property . Relational ( ) . ColumnName = property . Name . ToSnakeCase ( ) ;
32
31
}
33
-
32
+
33
+ // Convert primary key names from PascalCase to snake_case. E.g. PK_users -> pk_users
34
34
foreach ( var key in entity . GetKeys ( ) )
35
35
{
36
36
key . Relational ( ) . Name = key . Relational ( ) . Name . ToSnakeCase ( ) ;
37
37
}
38
38
39
+ // Convert foreign key names from PascalCase to snake_case.
39
40
foreach ( var key in entity . GetForeignKeys ( ) )
40
41
{
41
42
key . Relational ( ) . Name = key . Relational ( ) . Name . ToSnakeCase ( ) ;
42
43
}
43
-
44
+
45
+ // Convert index names from PascalCase to snake_case.
44
46
foreach ( var index in entity . GetIndexes ( ) )
45
47
{
46
48
index . Relational ( ) . Name = index . Relational ( ) . Name . ToSnakeCase ( ) ;
47
49
}
48
50
}
51
+
49
52
}
53
+
50
54
}
51
55
}
You can’t perform that action at this time.
0 commit comments