I would like to ask on why the >dotnet ef migrations add InitialMigration
behaves differently on these 2 program.cs code
Code 1:
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
Code 2
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
With Code-1, I am able to run >dotnet ef migrations add InitialMigration without an error. Using the PackageManager Console> add-migration Initial Migration No Error as well.
But with Code-2, I am having an Error on both Pakckage Manager Console and command prompt. Here is the error:
Unable to create an object of type 'AppDbContext'. Add an implementation of 'IDesignTimeDbContextFactory' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
As I understand it, both codes basically doing the same thing.