I downloaded the project and tried to run the sample.mvc.
when I use the command 'dotnet ef migrations add Initial' or 'dotnet ef database update', it occured the following mistake.
An error occurred while calling method 'ConfigureServices' on startup class 'Startup'. Consider using IDbContextFactory to override the initialization of the DbContext at design-time. Error: Unable to locate a project.json at 'E:\OpenSource\Identity-dev\samples\IdentitySample.Mvc\bin\Debug\netcoreapp1.0\'.
dotnet : No parameterless constructor was found on 'ApplicationDbContext'. Either add a parameterless constructor to 'ApplicationDbContext' or add an implementation of 'IDbContextFactory<ApplicationDbContext>' in the same assem
bly as 'ApplicationDbContext'.
and the ApplicationDbContext like
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
I didn't modify the code of 'Startup.cs'
@divega
I seem to be having a similar problem here. It looks like ApplicationDbContext is expecting the resolution that is offered by Startup but that Startup isn't executing. I get a more direct message...
No parameterless constructor was found on 'ApplicationDbContext'. Either add a parameterless constructor to 'ApplicationDbContext' or add an implementation of 'IDbContextFactory
I am having the same problem and the same error as @tiefling . THis happened to me in an exisitng application when I updated from 1.0 to 1.1 Preview 1.
I am using aspnet core /entityframework core on net 461.
Hi everyone,
Any fix to this?
If you hit this issue while upgrading web project from 1.0 to 1.1 (as case of @saad749 )
then it is actually breaking change in UserSecrets described here https://github.com/aspnet/Announcements/issues/209
You will need to add your usersecretsid as assembly attribute on your startup class using UserSecretsIdAttribute
Try dotnet ef --verbose migrations add Initial. Does this show additional details about what caused the command to fail?
@natemcmaster @smitpatel thanks so much both for the help!
Most helpful comment
I seem to be having a similar problem here. It looks like ApplicationDbContext is expecting the resolution that is offered by Startup but that Startup isn't executing. I get a more direct message...
No parameterless constructor was found on 'ApplicationDbContext'. Either add a parameterless constructor to 'ApplicationDbContext' or add an implementation of 'IDbContextFactory' in the same assembly as 'ApplicationDbContext'.