Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Factory need to use migration in .Net Core 2.1
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace StoreOfBuild.Data.Contexts
public class ContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
public ApplicationDbContext CreateDbContext()
return CreateDbContext(null);
public ApplicationDbContext CreateDbContext(string[] args)
var builderConfiguration = new ConfigurationBuilder()
var configuration = builderConfiguration.Build();
var connectionString = configuration.GetConnectionString("DefaultConnection");
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
return new ApplicationDbContext(builder.Options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.