简体   繁体   中英

How to register a user using asp net identity 2.0, mysql and database first approach?

I am using ASP.NET MVC 5 and MySQL and EF databasefirst approach. I work in VS 2015 enterpise.

In method:

public async Task<ActionResult> Register(RegisterViewModel model)

i am trying do register a new user. The problem is that i have an exception in this line:

var result = await UserManager.CreateAsync(user, model.password);

The user is an object of ApplicationUser class. The excetion message is: "The property Claims on type ApplicationUser is not a navigation property. The Reference and Collection methods can only be used with navigation properties. Use the Property or ComplexProperty method."

My question is what should I change in my ApplicationUser to register a new user?

I haven't tried this on MySQL but the error shows problem on your tables fk and pk. Check your tables design. Other reason for that could be your "model" incompleteness. Check to see your model contains all needed values to save on database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM