ApplicationUser - how do I use it? what do I need to put in my using clauses? azure entity-framework


I am trying to follow this tutorial but I'm stuck in the area where it tries to add ApplicationUser based code. The roles section.

dotnet deploy db based MVC site to azure

I did include these lines:

    using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;

My compile error

Error 1 The type or namespace name 'ApplicationUser' could not be found (are you missing a using directive or an assembly reference?) c:\users\blah\documents\visual studio 2013\Projects\blah\blah\Migrations\Configuration.cs 96 38 blah

edit: here's the whole snippet of code:

 bool AddUserAndRole(ContactManager.Models.ApplicationDbContext context)
    IdentityResult ir;
    var rm = new RoleManager<IdentityRole>
        (new RoleStore<IdentityRole>(context));
    ir = rm.Create(new IdentityRole("canEdit"));
    var um = new UserManager<ApplicationUser>(
        new UserStore<ApplicationUser>(context));
    var user = new ApplicationUser()
       UserName = "user1",
    ir = um.Create(user, "Passw0rd1");
    if (ir.Succeeded == false)
       return ir.Succeeded;
    ir = um.AddToRole(user.Id, "canEdit");
    return ir.Succeeded;
2/2/2014 10:42:44 AM

Accepted Answer

Did you create an ApplicationUser class which inherits from IdentityUser? If so, did you add the namespace, in which the ApplicationUser class is located, to the Configuration class?

That are the most reasonable things for resolving this error.

2/2/2014 1:38:10 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow