创建 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());

 

posted on 2019-04-12 17:40  gzh4455  阅读(527)  评论(0编辑  收藏  举报