Using Code First Migrations with the ADO.NET Entity Framework
- Last Updated: April 16, 2026
- 2 minute read
- ADO.NET
- Documentation
Entity Framework 4.3 and higher includes support for Code First Migrations which allows you to update your database schema to reflect POCO classes without having to drop and recreate them. This involves DDL statements such as to create new tables/columns, alter existing ones which get generated.
Migrations allow 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 have been 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 ADO.NET Oracle Data Provider, you must include the following additional settings:
- Add references to the DDTek.Oracle.Entity assembly in the project.
- Inherit the Configuration Class changes and register the SQL Generator in the constructor of the Configuration Class. Do the following steps:
a. Inherit the Configuration Class from OracleDbMigrationsConfiguration. For example: internal sealed class Configuration: OracleDbMigrationsConfiguration<%Context Name%>
b. Register the Class Generator.
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 app.config file, use the following syntax to register SQL Generator in app.config file:
SetSqlGenerator("DDTek.Oracle", new DDTek.Oracle.Entity.Migrations.OracleEntityMigrationSqlGenerator());
To register SQL Generator in configuration.cs, use the following syntax:
SetSqlGenerator(connectionInfo.GetInvariantName(), new OracleEntityMigrationSqlGenerator());