Tools: Remove logic to invoke Startup.ConfigureServices #8328
Labels
breaking-change
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-cleanup
Milestone
The ASP.NET Core templates are changing in a way that breaks how
dotnet ef
and the PMC commands invokeStartup.ConfigureServices()
at design-time to discover and instantiateDbContext
derived types.A new design-time entry point of
Program.BuildWebHost()
is being added, and we're considering adding first-class support for it in #8164.We're taking this opportunity to try a much simpler design-time approach and clean up some of the abstractions around
Startup.ConfigureServices()
that leaked into our implementation.The most noticeable change is that we're going to stop attempting to call
Startup.ConfigureServices()
. This means that if yourDbContext
derived type doesn't have a default constructor or isn't in either your startup or target project, you'll need to add an implementation ofIDbContextFactory<TContext>
. The tools will automatically discover this implementation on types in your startup or target project and use it. We've added a default implementation to the ASP.NET Core templates for 2.0.0-preview1 so EF Core Migrations commands will continue to work with new projects.The rippling effects of removing the
Startup.ConfigureServices()
code are as follows.--environment
(-Environment
in PMC) option ondotnet ef
is being removed. Use theASPNETCORE_ENVIRONMENT
environment variable instead.DbContextFactoryOptions
is being removed. UseAppContext.BaseDirectory
instead of theApplicationBasePath
property; andDirectory.GetCurrentDirectory()
instead ofContentRootPath
.ConfigureDesignTimeServices
on yourStartup
class. Instead, implement theIDesignTimeServices
interface on a type in your startup project.The text was updated successfully, but these errors were encountered: