Entity Framework Core RC2 table name pluralization

前端 未结 7 2294
谎友^
谎友^ 2020-12-05 01:50

Is there a way to do what this code did in EF Core RC 2?

protected override void OnModelCreating(ModelBuilder modelBuilder)
{    
    modelBuilder.Convention         


        
7条回答
  •  Happy的楠姐
    2020-12-05 02:23

    The EF Core version doesn't seem to support entity.DisplayName. This is a working alternative:

    foreach (var entityType in modelBuilder.Model.GetEntityTypes())
    {
        // Skip shadow types
        if (entityType.ClrType == null)
            continue;
    
        entityType.Relational().TableName = entityType.ClrType.Name;
    }
    

提交回复
热议问题