Closed shawnwildermuth closed 7 years ago
Dupe of #8164. This will be fixed in 2.0.0-preview2-final.
ASP.NET Core changed the default pattern for applications in 2.0. Instead of having a ConfigureServices call, there is now a Main method with a BuildWebHost method split out. It was explicitly stated by @DamianEdwards that EF does not need to try to keep supporting the old pattern and instead old applications should:
However, our exception message only suggests the latter, which means that people will not be aware that updating their app to the new pattern is a solution. We should update the message with a fwlink (@divega) to documentation on how to update 1.x ASP.NET Core app to the 2.0 pattern.
I have created https://go.microsoft.com/fwlink/?linkid=851728. Currently it points to one of the ASP.NET Core walkthroughs, but we should update it as part of https://github.com/aspnet/EntityFramework.Docs/issues/409.
I don't quite get this, does this mean that for separate data projects, we no longer need a startup class to support EF Tooling? Instead we should do what in Main to support it without needing to implement the IDbContextFactory? I'm seeing this is a new 2.0 project, not a converted 1.x project.
This is the program.cs:
namespace VacationPicker
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}
@shawnwildermuth AFAIR, in 2.0-preview1 we were in an intermediary state in which we didn't support the Program.BuildWebHost
method so you had to have an IDbContextFactory
. The change to support Program.BuildWebHost
is in preview2.
Describe what is not working as expected.
I expected that the startup registration would allow me to use the EF Tools without implementing a IDbConnectionFactory. I do not have an empty constructor on my context class, but by isn't the tooling using DI to create an instance? Here is my DbContext class:
If you are seeing an exception, include the full exceptions details (message and stack trace).
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
Further technical details
EF Core version: (found in .csproj file)
Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: Win10 IDE: VS2017 Preview 1