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;
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With