MVC 5 Identity issue: Tried change the registration form to user a user name. The default is sets to email But i need real user names I get error when I change to UserName. I made 2 changes

I get the error message below, when I try to register a user on my MVC5 website.  I need the registration to user a real user name not the email. The default setting is set to user email for user name out of the box.  I made two changes that i thought should work.  

1st, In the Register Post Action on the AccountController set it to UserName rather than Email

 2ed,  I changed the following code and add UserName to the RegisterViewModel
<div class="form-group">
        @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
            @Html.TextBoxFor(m => m.UserName, new { @class = "form-control", @placeholder = "Username or email" })
        </div>

Open in new window



Again this is so it will not use the email as the UserName when visiters register.

Now this is the Error message I get:
'MVCMemberApp.Models.RegisterViewModel' does not contain a definition for 'UserName' and no extension method 'UserName' accepting a first argument of type 'MVCMemberApp.Models.RegisterViewModel' could be found (are you missing a using directive or an assembly reference?)

Open in new window


Note: the code worked with email

Thanks for any help!
bmanmike39Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ronak PatelCommented:
Hi bmanmike39,

From the error message, it seems like the "UserName" property is missing in your RegisterViewModel's model definition.

You need to add the "UserName" property to your model in order to use it on the View.


Hope this helps.

Regards,
Ronak
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bmanmike39Author Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.