1 , Global.asax.cs添加如下代码:Database.SetInitializer<EFDbContext>(null);
2 ,修改表结构 ,
3 ,修改实体类和表结构同步
4 ,如果第一次数据迁移 执行以下代码:

Enable-Migrations -ProjectName SportStore.Domain -ContextTypeName SportStore.Domain.Entities.Concrete.EFDbContext

add-migration -ProjectName SportStore.Domain Initial

update-database -ProjectName SportStore.Domain

 

5,如果不是第一次,执行代码:

Enable-Migrations -Force -ProjectName SportStore.Domain -ContextTypeName SportStore.Domain.Entities.Concrete.EFDbContext
add-migration -Force -ProjectName SportStore.Domain Initial
update-database –Verbose -ProjectName SportStore.Domain

相关文章:

  • 2021-08-08
  • 2021-10-28
  • 2021-09-02
  • 2021-12-30
  • 2022-03-07
  • 2021-09-13
  • 2021-06-26
猜你喜欢
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案