Using Code First Migrations with the ADO.NET Entity Framework
Entity Framework 4.3 and later support Code First Migrations, which enables you to update your database schema to reflect POCO classes without having to drop and recreate them.
Migrations enable you to incrementally evolve your database schema as your model changes. Each set of changes to the database is expressed in a code file, known as a migration. The migrations are ordered, typically using a timestamp, and a table in the database keeps track of which migrations are applied to the database.
Code First Migrations implementation requires type mapping changes. See Mapping Data Types and Functions for more information,
To implement Code First Migrations using Progress DataDirect Connect for PSQL ADO.NET Data Provider, you must perform the following additional settings:
1
2
a.
Inherit the Configuration Class from PervasiveDbMigrationsConfiguration <TContext>. For example:
internal sealed class Configuration: PervasiveDbMigrationsConfiguration<%Context Name%>
b.
After you enable migrations using Package Manager Console, specify the Connection String either in the app.config or configuration.cs file along with additional settings in the configuration.cs file. However, if Connection String is specified in the app.config file, then ensure that the Connection String and the context have the same name.
If the Connection String is specified in the app.config file, use the following syntax to register SQL Generator in the app.config file:
SetSqlGenerator("DDTek.Pervasive", new DDTek.Pervasive.Entity.Migrations.PervasiveEntityMigrationSqlGenerator());
To register SQL Generator in configuration.cs, use the following syntax:
SetSqlGenerator(connectionInfo.GetInvariantName(), new PervasiveEntityMigrationSqlGenerator());