Hello
I have created an angular/asp.net core mvc application last weeks.
Everything was working fine.
I have added this line in startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<BddContext>(options => options.UseMySQL("Server=localhost;Database=testspa;Uid=root;Pwd=123456;"));
But today, i needed to create a new project, i get this error:
"Unable to create an object of type 'BddContext'. Add an implementation of 'IDesignTimeDbContextFactory<BddContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time."
I needed to remove the services.AddDbContext and i needed to create this file to make it works !
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<BddContext>
{
public BddContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<BddContext>();
builder.UseMySQL("Server=localhost;Database=testspa;Uid=root;Pwd=123456;");
return new BddContext(builder.Options);
}
}
}
It now work fine but my question is why should i need this file while it was working great before ?
Thanks
aa