title: Error Registering ApplicationUser: 'Invalid Column Name *_Id' using Entity Framework
body: <p>I am having an issue that I have not been able to find a solution for.</p>
  
  <p>I am attempting to build out a Saas Monthly billing solution similar to <a href="https://code.tutsplus.com/tutorials/building-a-note-taking-saas-using-aspnet-mvc-5--cms-22922" rel="nofollow noreferrer">this</a>.  I am using the SaasEcomm git code to add additional fields and functionality to the ApplicationUser. See below I am using the <a href="http://saas-ecom/SaasEcom.Core/Models/SaasEcomUser.cs" rel="nofollow noreferrer">SaasEomUser class</a> and adding additional fields and billing address.</p>
  
  <pre><code>public class ApplicationUser : SaasEcomUser //Instead of IdentityUser
  {
      public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser&gt; manager)
      {
          // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
          var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
          return userIdentity;
      }
  
      public virtual BillingAddress BillingAddress { get; set; }
  }
  </code></pre>
  
  <p>The error message I get makes me think Entity Framework is getting confused what the appropriate ID is but have not had any luck fixing it:</p>
  
  <p><a href="https://i.stack.imgur.com/n3S7B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n3S7B.png" alt="Invalid column name &#39;SaasEcomUser_Id&#39;."></a></p>
  
  <p>I don't have 'SaasEcomUser_Id' anywhere in my code so that's why I think it's Entity Framework. Here is the code (CreateAsync) that is getting called on the error:</p>
  
  <pre><code>    [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public async Task&lt;ActionResult&gt; Register(RegisterViewModel model)
      {
          model.SubscriptionPlan = "basic_monthly";
  
          if (ModelState.IsValid)
          {
              var user = new ApplicationUser
              {
                  UserName = model.Email,
                  Email = model.Email,
                  RegistrationDate = DateTime.Now,
                  LastLoginTime = DateTime.Now,
                  BillingAddress = new BillingAddress()
              };
  
              var result = await UserManager.CreateAsync(user, model.Password);
  
          return View(model);
      }
  </code></pre>
  
  <p>OnModelCreating:</p>
  
  <pre><code> protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;ApplicationUser&gt;().HasKey&lt;string&gt;(m =&gt; m.Id);
  
          modelBuilder.Entity&lt;ApplicationUser&gt;().Map(m =&gt; m.MapInheritedProperties());
  
          base.OnModelCreating(modelBuilder);
      }
  </code></pre>
  
  <p>I may be way off base but is there a way of letting EF know that the primary key is Id instead? Or is something else wrong?  </p>
  
  <p>Thank you to anyone that can help, in advance! If there is any other code I can provide please let me know!</p>