私は例えば、私は単一のテーブルのスキーマをspecifiyすることができますEntityTypeConfiguration<Role>
派生クラスからこの抜粋で指定したユーザーのロール多対多の関係を持っている:多対多リレーションシップテーブルのスキーマを指定する方法は?
[Schema(SchemaNames.ParkPay)]
class WeekDayConfig : EntityTypeConfigurationWithSchema<WeekDay>
{
internal WeekDayConfig()
{
Ignore(t => t.IsDeleted);
Property(p => p.Name)
.IsRequired()
.HasMaxLength(20);
}
}
、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");
});
}
}
は、私が「parkpay」スキーマではなく「DBO」スキーマの下に作成されたテーブルUserRole
を持つように、初期の播種期にスクリプトスキーマの変更を除いて、何かできることはありますか?
あなたはこれを試してみましたか? ToTableのオーバーロードのように見えます:http://stackoverflow.com/questions/6028375/entity-framework-code-first-many-to-many-setup-for-existing-tables – rliu