EF Error when adding migration
I'm getting this error:
I have defined this in the program.cs
This is my ApplicationDbContext.cs
10 Replies
@Julian Can you share the entire ApplicationDbContext object?
@SwaggerLife Sure!
Try
overriding
the OnConfiguring
method.
Does this make any difference?Nope
what if you change your constructor to accept
DbContextOptions<ApplicationDbContext>
?Ohh shit, yeah. Yeah you need that.
I tried this:
And this worked. But I'll try it out. Not my project, but I've used EF like 2 times.. I'm a Dapper user
D:
yeah don't do that, that's bad if you're using DI
now you can only ever use your dbcontext with that connection string and it's hardcoded in your program
See if this helps you. Near the bottom is code that resembles yours. https://stackoverflow.com/questions/19902756/asp-net-identity-dbcontext-confusion
Stack Overflow
ASP.NET Identity DbContext confusion
A default MVC 5 App comes with this piece of code in IdentityModels.cs - this piece of code is for all the ASP.NET Identity operations for the default templates:
public class ApplicationDbContext :