EF删除表后如何恢复

1.使用命令生成一个文件 migration5

add-migration migration5

2.把之前migration1中生成表的数据复制过来

public override void Up()
     {
         CreateTable(
             "dbo.User_Table",
             c => new
             {
                 ID = c.Int(nullable: false, identity: true),
                 UserName = c.String(),
                 PassWord = c.String(),
                 CardNumber = c.String(),
                 DeptID = c.String(),
                 DeptName = c.String(),
                 Status = c.Int(nullable: false),
                 IsAdmin= c.Int(nullable: false),
                 UpdateTime = c.DateTime(nullable: false),
             })
             .PrimaryKey(t => t.ID);
     }
     public override void Down()
     {
         DropTable("dbo.User_Table");
     }
View Code

 

3.执行 Update()-Database

posted @ 2025-01-22 10:20  三石PY  阅读(22)  评论(0)    收藏  举报