Migration-添加表

 public partial class _111111 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.AssetBorrows",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        WFSheetNO = c.String(),
                        ApplyUserName = c.String(),
                        ApplyDept = c.String(),
                        Phone = c.String(),
                        ApplyDate = c.DateTime(),
                        BorrowAsset = c.String(),
                        BorrowReason = c.String(),
                        IsSure = c.Boolean(nullable: false),
                        Created = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            //AddColumn("dbo.Assets", "AssetBorrow_Id", c => c.Guid());
            //AddColumn("dbo.Dispositions", "Property1", c => c.Boolean());
            //AlterColumn("dbo.Dispositions", "IsDisposal", c => c.String());
            //CreateIndex("dbo.Assets", "AssetBorrow_Id");
            //AddForeignKey("dbo.Assets", "AssetBorrow_Id", "dbo.AssetBorrows", "Id");
        }
        
        public override void Down()
        {
        //    DropForeignKey("dbo.Assets", "AssetBorrow_Id", "dbo.AssetBorrows");
        //    DropIndex("dbo.Assets", new[] { "AssetBorrow_Id" });
        //    AlterColumn("dbo.Dispositions", "IsDisposal", c => c.Boolean());
        //    DropColumn("dbo.Dispositions", "Property1");
        //    DropColumn("dbo.Assets", "AssetBorrow_Id");
            DropTable("dbo.AssetBorrows");
        }
    }
原文地址:https://www.cnblogs.com/lishidefengchen/p/5549362.html