I tried to write a MVC application with ASP.net Identity from scratch. To do so I followed two tutorials from Ben Foster (Tutorial Part1 and Tutorial Part2)
But I stuck at the second tutorial - Configuring UserManager. The following line doesn't work for me:
// configure the user manager
UserManagerFactory = () =>
{
var usermanager = new UserManager<AppUser>(
new UserStore<AppUser>(new AppDbContext()));
...
}
Visual Studio underlines
new AppDbContext()
and shows me the following message:
Argument type "MyProject.DbContext.AppDbContext" is not assignable to parameter type "System.Data.Entity.DbContext"
I don't understand why it doesn't work in my solution because I followed completely the tutorial. My AppDbContext looks like:
namespace MyProject.DbContext
{
using MyProject.Models;
using Microsoft.AspNet.Identity.EntityFramework;
public class AppDbContext : IdentityDbContext<User>
{
public AppDbContext()
: base("DefaultConnection")
{
}
}
}
My User class:
namespace MyProject.Models
{
using Microsoft.AspNet.Identity.EntityFramework;
public class User : IdentityUser
{
public string Name{ get; set; }
}
}
I also downloaded the source code from Ben and tried to run it and it works without any problems. I think it doesn't make any difference that all of my files aren't located in the same folder?!
I hope you can help me. It's really frustrating if a simple tutorial doesn't work as it should...
Regards, winklerrr
I solved the problem by removing all the references that had something to do with owin and ASP.net Identity and re-added them again.
I think, the problem was caused by a discrepancy between the referenced dlls and the actual used dlls... (Played to much with the package manager console.)