Unable to create an object of type 'ApplicationDbContext'. For the different patterns supported at design time

I found the cause of this error could be multiple things in your code. For me at least, the best way was to add verbose in command.

With that will be able to understand what is the problem. the verbose will display all steps of the execution.

In visual studio use:

add-migration Added_something -verbose

For the CLI use:

dotnet ef migrations add Added_something  --verbose

This error can also occur if multiple startup projects is selected. I set my webproject to startup project and that solved the issue for me.


Seems you are your inheritance is wrong.

public ApplicationDbContext : IdentityDbContext

should be

public ApplicationDbContext : IdentityDbContext<ApplicationUser>

or

public ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole>

if you also extend roles class.

when you want to create an context with an extended user class (instead of IdentityUser)