码迷,mamicode.com
首页 > 数据库 > 详细

DbMigration 外键删除修改

时间:2015-11-12 13:16:15      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:

 public partial class _20151112 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.T_RoleProductModule", "Product_Id", "dbo.T_Product");
            DropIndex("dbo.T_RoleProductModule", new[] { "Product_Id" });
            AddColumn("dbo.T_RoleProductModule", "RoleProduct_Id", c => c.Int());
            CreateIndex("dbo.T_RoleProductModule", "RoleProduct_Id");
            AddForeignKey("dbo.T_RoleProductModule", "RoleProduct_Id", "dbo.T_RoleProduct", "Id");
            DropColumn("dbo.T_RoleProductModule", "Product_Id");
        }
        
        public override void Down()
        {
            AddColumn("dbo.T_RoleProductModule", "Product_Id", c => c.Int());
            DropForeignKey("dbo.T_RoleProductModule", "RoleProduct_Id", "dbo.T_RoleProduct");
            DropIndex("dbo.T_RoleProductModule", new[] { "RoleProduct_Id" });
            DropColumn("dbo.T_RoleProductModule", "RoleProduct_Id");
            CreateIndex("dbo.T_RoleProductModule", "Product_Id");
            AddForeignKey("dbo.T_RoleProductModule", "Product_Id", "dbo.T_Product", "Id");
        }
    }

 

DbMigration 外键删除修改

标签:

原文地址:http://www.cnblogs.com/liucai/p/4958518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!