Powered by Zoomin Software. For more details please contactZoomin

DataDirect Connect for ADO.NET Data Provider Help

Using Code First Migrations with the ADO.NET Entity Framework

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 later support Code First Migrations, which enables 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 that get generated.

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 ADO.NET DB2 Data Provider, you must perform the following additional settings:

  1. Add references to the DDTek.DB2.Entity assembly in the project.
  2. Inherit the Configuration Class changes and register the SQL Generator in the constructor of the Configuration Class. Do the following:
    a. Inherit the Configuration Class from DB2DbMigrationsConfiguration . For example: internal sealed class Configuration: DB2DbMigrationsConfiguration<%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 the app.config file, use the following syntax to register SQL Generator in the app.config file:

SetSqlGenerator("DDTek.DB2", new DDTek.DB2.Entity.Migrations.DB2EntityMigrationSqlGenerator());

To register SQL Generator in configuration.cs, use the following syntax:

SetSqlGenerator(connectionInfo.GetInvariantName(), new DB2EntityMigrationSqlGenerator());
TitleResults for “How to create a CRG?”Also Available inAlert