0

The code below is meant to store this user (I'm using Visual Studio and SQL Server Management Studio 2018). However, when I go onto the server and type SEARCH * FROM dbo.AspNetUsers, the user I created does not come up on SSMS. I'm pretty sure my code should work but I don't know why I can't see it in SSMS.

public void Configuration(IAppBuilder app)
{
    ConfigureAuth(app);
    CreateUserAndRoles();
}

public void CreateUserAndRoles()
{
    ApplicationDbContext context = new ApplicationDbContext();

    var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());
    var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());

    if (!roleManager.RoleExists("SuperAdmin"))
    {
        //Create Super Admin Role 
        var role = new IdentityRole("SuperAdmin");
        roleManager.Create(role);

        //Create Default User 
        var user = new ApplicationUser();
        user.UserName = "admin@swansea.ac.uk";
        user.Email = "admin@swansea.ac.uk";
        string pwd = "Password@2019";

        var newuser = userManager.Create(user, pwd);
        if (newuser.Succeeded)
        {
            userManager.AddToRole(user.Id, "SuperAdmin");
        }
    }
}
Swift
  • 15
  • 3

0 Answers0