Question

I have this table called Demographics that is related to the aspnet_Users table by the userId field. This Demographics table has about 20 fields that must inserted at the point that the user registers for the site.

I'm able to capture the aspnet_Users.UserId of the just registered user in the Register(RegisterModel model) controller action, but how do I go about setting the properties in the Demographics class (EF autogenerated this Model class and it's in a separate project) for this user? All the values for the Demographics class should come from the registration page created by Microsoft.

aspnet_Users(UserId, etc....)

Demographics(UserId, FirstName, LastName, Address, AgeRange, etc...)

Était-ce utile?

La solution

You will have to create a View Model that incorporates necessary information for the UserMembership and the Demographics. Then you can just have your Create controller for the User call the Register(RegisterModel model) and also call the Register(Demographics demo)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top