Entity Framework Code-First(20):Migration

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Entity Framework Code-First(20):Migration相关的知识,希望对你有一定的参考价值。

Migration in Code-First:

Entity framework Code-First had different database initialization strategies prior to EF 4.3 like CreateDatabaseIfNotExists, DropCreateDatabaseIfModelChanges, or DropCreateDatabaseAlways. However, there were some problems with these strategies, for example if you already have data (other than seed data) or existing Stored Procedures, triggers etc in your database, these strategies used to drop the entire database and recreate it, so you would lose the data and other DB objects.

Entity framework 4.3 has introduced a migration tool that automatically updates the database schema, when your model changes without losing any existing data or other database objects. It uses a new database initializer called MigrateDatabaseToLatestVersion.

There are two kinds of Migration:

  1. Automated Migration
  2. Code based Migration

Learn about automated migration in the next section.

以上是关于Entity Framework Code-First(20):Migration的主要内容,如果未能解决你的问题,请参考以下文章

Entity Framework Code-First(23):Entity Framework Power Tools

Entity Framework怎么GroupBY多个字段

entity framework 公共类

Entity Framework Fluent API

初步了解Entity Framework

Entity Framework 中的in操作实例