Entity Framework Code First 有没有办法不在数据库生成外键约束
1个回答
展开全部
public class ExtendedSqlGenerator : SqlServerMigrationSqlGenerator
{
#region 外键
protected override void Generate(DropForeignKeyOperation dropForeignKeyOperation)
{
if (IsIgnoreTable(dropForeignKeyOperation.DependentTable))
return;
base.Generate(dropForeignKeyOperation);
}
protected override void Generate(AddForeignKeyOperation addForeignKeyOperation)
{
if (IsIgnoreTable(addForeignKeyOperation.DependentTable))
return;
base.Generate(addForeignKeyOperation);
}
#endregion
}
{
#region 外键
protected override void Generate(DropForeignKeyOperation dropForeignKeyOperation)
{
if (IsIgnoreTable(dropForeignKeyOperation.DependentTable))
return;
base.Generate(dropForeignKeyOperation);
}
protected override void Generate(AddForeignKeyOperation addForeignKeyOperation)
{
if (IsIgnoreTable(addForeignKeyOperation.DependentTable))
return;
base.Generate(addForeignKeyOperation);
}
#endregion
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询