Pro*_*ofK 6 entity-framework ef-code-first entity-framework-5
我有一个用户角色多对多关系,这个摘录是从EntityTypeConfiguration<Role>派生类中指定的,它允许我为单个表指定模式,例如:
[Schema(SchemaNames.ParkPay)]
class WeekDayConfig : EntityTypeConfigurationWithSchema<WeekDay>
{
internal WeekDayConfig()
{
Ignore(t => t.IsDeleted);
Property(p => p.Name)
.IsRequired()
.HasMaxLength(20);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,for,for Role配置类包含此代码,结果表UserRole在'dbo'模式下创建,而不是我想要的模式.这是代码:
[Schema(SchemaNames.ParkPay)]
internal class RoleConfig : EntityTypeConfigurationWithSchema<Role>
{
public RoleConfig()
{
HasMany(t => t.Users)
.WithMany(t => t.Roles)
.Map(m =>
{
m.ToTable("UserRole");
m.MapLeftKey("RoleId");
m.MapRightKey("UserId");
});
}
}
Run Code Online (Sandbox Code Playgroud)
有什么我可以做的,除了脚本在初始化的播种阶段更改模式,UserRole在'parkpay'模式下创建表而不是'dbo'模式?
SOf*_*tic 10
我不明白为什么这不起作用:
public RoleConfig()
{
HasMany(t => t.Users)
.WithMany(t => t.Roles)
.Map(m =>
{
m.ToTable("UserRole","parkpay");
m.MapLeftKey("RoleId");
m.MapRightKey("UserId");
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1525 次 |
| 最近记录: |