Crudler
Crudler

Reputation: 2286

MVC5 EF6 with migrations - seeding a membership user

I am setting up my seed methods in my migration's configuration class.

I have added a reference to the following name spaces

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

and wrote up the following method that gets called from the Seed method

private void SeedMembership(MyDbContext context)
    {

            var user = new ApplicationUser() { UserName = "demo"};
            UserManager<ApplicationUser> userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
            var result = UserManager.Create(user,"demo");


    }

The idea was to have this aoto create a user with username=demo and password=demo

but I cant compile getting the following error:

using the generic type 'Microsoft.AspNet.Identity.UserManager<TUser>' requires 1 type argument

I am a bit stuck as to why.

Thanks!

Upvotes: 1

Views: 641

Answers (1)

Dan
Dan

Reputation: 209

You seem to have a typo:

var result = UserManager.Create(user,"demo");

You should use userManager, note the lower-case u.

Upvotes: 2

Related Questions