This project is read-only.

Create account with custom properties

Mar 29, 2013 at 7:31 PM
Looking to extend the CreateUserAndAccount method - I see that your UserProfile entity has added a custom field [Email] and that executing an EF migration will create an email field in the db. But your seed method is not sending an email.

I've played around with custom properties in the stock SimpleMembership provider and am able to seed accounts with:
            if (!WebSecurity.UserExists("SeedUser2"))
                WebSecurity.CreateUserAndAccount(
                    "SeedUser2",
                    "Pass",
                    new
                    {
                        FirstName = "Seed",
                        LastName = "User2",
                        Middle = "",
                        Title = "SeedUser2 Second",
                        Email = "User2@thisDomain.com",
                        DomainName = "ThisDomain.com",
                        Institution = "Company 2"
                    });
Wondering what adjustments need to be made to your project to achieve similar.

thx much
May 6, 2013 at 7:09 PM
justSteve - Sorry for the late reply. For some reason I did not get a notification when your question was posted.

Not sure if I understand the question, but you should be able to use the exact same code you posted above in the seed method for the example I gave for seeding. Or you can extend the CreateUserAndAccount as I did when I decoupled SimpleMembership as discussed in this article. When I decoupled SimpleMembership I created a wrapper for WebSecurity that extends it and includes the email as a parameter when using CreateUserAndAccount. If you use the example from this article you will have code that looks like this.
            if (!WebSecurity.FoundUser("test"))
            {
                WebSecurity.CreateUserAndAccount("test", "password", "test@gmail.com");
            }
If you get the latest version of the source code for this project you will see that I changed the seed method to use this since it is a better example of how to use the extended profile.

Thank you for pointing this out.