title: WebSecurity.CreateUserAndAccount "Field does not exist"
body: <p>I am trying to extend the Simple Membership to include FirstName, SecondName and Email address, however I am getting some problems with the CreateUserAndAccount.</p>
  
  <p>So basically in the RegisterModel I have added the following :-</p>
  
  <pre><code>    [Display(Name = "First Name")]
      [Required(ErrorMessage = "Text is required")]
      public string FirstName { get; set; }
  
      [Display(Name = "Second Name")]
      [Required(ErrorMessage = "Text is required")]
      public string SecondName { get; set; }
  
      [Display(Name = "Email")]
      [Required(ErrorMessage = "Email required")]
      [RegularExpression(@"^\w+([-+.]*[\w-]+)*@(\w+([-.]?\w+)){1,}\.\w{2,4}$")]
      public string ContactEmail { get; set; }
  </code></pre>
  
  <p>in the Register.cshtml I have added the user inputs :-</p>
  
  <pre><code>        &lt;li&gt;
              @Html.LabelFor(m =&gt; m.FirstName)
              @Html.TextBoxFor(m =&gt; m.FirstName)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.SecondName)
              @Html.TextBoxFor(m =&gt; m.SecondName)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.ContactEmail)
              @Html.TextBoxFor(m =&gt; m.ContactEmail)
          &lt;/li&gt;
  </code></pre>
  
  <p>and then in the AccountController.cs I have the following :-</p>
  
  <pre><code>    [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public ActionResult Register(RegisterModel model)
      {
          if (ModelState.IsValid)
          {
              // Attempt to register the user
              try
              {
                  var UserInfo =
                  new
                  {
                      FirstName = model.FirstName,
                      SecondName = model.SecondName,
                      ContactEmail = model.ContactEmail
                  };
  
                  WebSecurity.CreateUserAndAccount(model.UserName, model.Password, UserInfo);
                  WebSecurity.Login(model.UserName, model.Password);
                  return RedirectToAction("Index", "Home");
              }
              catch (MembershipCreateUserException e)
              {
                  ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
              }
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>
  
  <p>The problem is that when it tries to do the </p>
  
  <pre><code>WebSecurity.CreateUserAndAccount(model.UserName, model.Password, UserInfo);
  </code></pre>
  
  <p>I am getting an error with the following :-</p>
  
  <p>Invalid column name 'FirstName'.</p>
  
  <p>Invalid column name 'SecondName'.</p>
  
  <p>Invalid column name 'ContactEmail'.</p>
  
  <p>Is it because the User table is not being created with the fields?  If it is, how can I create those fields.  I already have the initialize set</p>
  
  <pre><code>        WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
  </code></pre>
  
  <p>Any help is very much appreciated.</p>
  
  <p>Thanks</p>
  
  <p><em><strong></em>**<em>*</em>*</strong><em>UPDATE</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**</strong></p>
  
  <p>This is the UserProfile</p>
  
  <pre><code>    public class UserProfile : ProfileBase
  {
      [Display(Name = "First Name")]
      public virtual string FirstName
      {
          get
          {
              return (this.GetPropertyValue("FirstName").ToString());
          }
          set
          {
              this.SetPropertyValue("FirstName", value);
          }
      }
  
      [Display(Name = "Last Name")]
      public virtual string LastName
      {
          get
          {
              return (this.GetPropertyValue("LastName").ToString());
          }
          set
          {
              this.SetPropertyValue("LastName", value);
          }
      }
  
      [Display(Name = "Contact Email")]
      public virtual string ContactEmail
      {
          get
          {
              return (this.GetPropertyValue("ContactEmail").ToString());
          }
          set
          {
              this.SetPropertyValue("ContactEmail", value);
          }
      }
  
      public static UserProfile GetProfile(string username)
      {
          return Create(username) as UserProfile;
      }
  }
  </code></pre>