How to setup ef6 migrations with asp net core


Setting up EF6 migrations with ASP.NET Core can be a bit tricky, as EF6 is primarily designed to work with the full .NET Framework, while ASP.NET Core uses a -platform version called .NET Core. However, with a few workarounds, it is possible to use EF6 migrations in an ASP.NET Core project.

Step 1: Install EF6

The first step is to install EF6 in your ASP.NET Core project. To do this, open the Package Manager Console in Visual and run the command:

Install-Package EntityFramework -Version 6.4.4

This will install EF6 in your project and add the necessary references.

Step 2: Configure EF6

Next, you need to configure EF6 to work with ASP.NET Core. In your Startup.cs file, add the following code to the method:

This code configures EF6 to use the SQL Server database . Replace YourDbContext with the name of your DbContext class, and DefaultConnection with the name of your connection string.

Step 3: Create a

Now that EF6 is set up, you can create a migration. Open the Package Manager Console again and run the following command:

Add-Migration InitialCreate

This will create a new migration “InitialCreate” in your project. You can replace “InitialCreate” with any name you prefer.

Step 4: the Migration

Finally, you can apply the migration to your database. Run the following command in the Package Manager Console:


This will apply the migration and update your database accordingly.


By following these steps, you can set up EF6 migrations in your ASP.NET Core project. Although it requires some additional configuration, it allows you to leverage the power of EF6 in your cross-platform applications.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents