1
我有一个应用程序包含IdentityDbContext,我想选择使用ServiceStack.OrmLite数据,我想知道我怎么可以改变别名更改表的别名运行时ServiceStack.OrmLite
public class ApplicationDbContext : IdentityDbContext<User>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<User>().ToTable("User");
builder.Entity<IdentityRole>().ToTable("Role");
builder.Entity<IdentityUserRole<string>>().ToTable("UserRole");
builder.Entity<IdentityUserClaim<string>>().ToTable("UserClaim");
builder.Entity<IdentityUserLogin<string>>().ToTable("UserLogin");
}
}
我试着代码低于但它不工作:
ModelDefinition<User>.Definition.Alias = "Users";
ModelDefinition<IdentityRole>.Definition.Alias = "Roles";
ModelDefinition<IdentityUserRole<string>>.Definition.Alias = "UserRoles";
ModelDefinition<IdentityUserClaim<string>>.Definition.Alias = "UserClaims";
ModelDefinition<IdentityUserLogin<string>>.Definition.Alias = "UserLogins";
你好@mythz。这里我有一个问题,当我尝试从EntityFramework IdentityUser中读取同样的模型时,我们会看到如下错误:'PostgresException:42703:column“Roles”不存在,因为'Roles'属性的类型是'ICollection'。你有什么解决方案吗? –