这里我想讲清楚code first 数据迁移的两种模式,还有开发环境和生产环境数据迁移的最佳实践. 1.1 数据迁移综述 EF Code first 虽然已经有了几种不同的数据库初始化策略,但是大部分策略都会造成现有的数据丢失,所以如果我们想更新实体的结构,但是保留数据的话,EF提供了一个数据迁移的工具,它使用了新的数据库初始化策略叫做 MigrateDatabaseToLatestVersion,启用数据迁移之后,需要把数据库初始化策略修改为此策略. 一共有两种迁移模式: Automated
Model compatibility cannot be checked because the EdmMetadata type was not included in the model. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions. 分析: 碰到此错误是由于使用了EF Code First来生成数据库,生成数据库之后又修改了模型. 两种解决方式: 1.在Glo