Category Archives: Code First Migrations

EF 6.1: Creating indexes with IndexAttribute

Since EF 4.3 it has been possible to use CreateIndex and DropIndex in Code First Migrations to create and drop indexes. However this had to be done manually by editing the migration because the index was not included anywhere in … Continue reading

Posted in Code First, Code First Migrations, Data Annotations, Entity Framework | Tagged , , , , , | 19 Comments

Database initializer and Migrations Seed methods

Entity Framework contains two different methods both called Seed that do similar things but behave slightly differently. The first was introduced in EF 4.1 and works with database initializers. The second was introduced in EF 4.3 as part of Code … Continue reading

Posted in Code First, Code First Migrations, Database Initializers, DbContext API, Entity Framework | Tagged , , , , , , , , | 6 Comments

Code First Migrations: Making __MigrationHistory not a system table

Code First Migrations uses a table called __MigrationHistory as a place to store metadata about the migrations that have been applied to the database. Code First creates this table when it creates a database or when migrations are enabled. In … Continue reading

Posted in Code First, Code First Migrations, Entity Framework | Tagged , , , , | 16 Comments