Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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;
 }
like image 835
Neo42 Avatar asked Feb 01 '14 19:02

Neo42


1 Answers

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.

like image 185
Horizon_Net Avatar answered Oct 19 '22 01:10

Horizon_Net