创建 ExtendedSqlGenerator类
public class ExtendedSqlGenerator : SqlServerMigrationSqlGenerator { #region 外键 protected override void Generate(DropForeignKeyOperation dropForeignKeyOperation) { return; } protected override void Generate(AddForeignKeyOperation addForeignKeyOperation) { return; } #endregion }
在Configuration类的构造函数里添加SetSqlGenerator("System.Data.SqlClient", new ExtendedSqlGenerator());