MigrationsExtensionsDbContextDesignTimeFactory Class - denmitchell/EDennis.AspNetCore.Base GitHub Wiki
This class is a generic implementation of Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory. The class makes it easier to use Entity Framework Migrations with DbContext classes that have only a single constructor taking DbContextOptions as a parameter.
Special Note: The class targets SQL Server only, and it requires the following NuGet package: EDennis.MigrationsExtensions
Usage Steps
- Create a subclass of MigrationsExtensionsDbContextDesignTimeFactory, where the type parameter is the name of your DbContext class.
- Create a ConnectionStrings object in appsettings.Development.json and add a property whose key is the name of your DbContext class and whose value is the connection string.
Example
public class AgencyInvestigatorCheckContextDesignTimeFactory :
MigrationsExtensionsDbContextDesignTimeFactory<AgencyInvestigatorCheckContext> { }