title: Register Async not working after moving identity model and dbcontext to Class Library
body: <p>I realized that my register async function that was created by default stopped working after I moved my IdentityModel to a Class Library and made my application reference it. </p>
  
  <p>I based my changes on this link <a href="https://stackoverflow.com/questions/23446919/moving-asp-net-identity-model-to-class-library">Moving ASP.NET Identity model to class library</a></p>
  
  <p>Currently my DbContext and Migrations all sit within my class library with my Application holding the connection string. Have I missed something when moving it across? </p>
  
  <p>This is the register function in my main application:</p>
  
  <pre><code>// POST: /Account/Register
          [HttpPost]
          [AllowAnonymous]
          [ValidateAntiForgeryToken]
          public async Task&lt;ActionResult&gt; Register(RegisterViewModel model)
          {
              if (ModelState.IsValid)
              {
                  var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                  var result = await UserManager.CreateAsync(user, model.Password);
                  if (result.Succeeded)
                  {
                      var ued = new AspNetUsersExtendedDetails
                      {
                          FirstName = model.FirstName,
                          LastName = model.LastName,
                          Address = "",
                          Notes = "",
                          UserId = user.Id
                      };
                      RegisterExtendedDetails(ued);
                      await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
  
                      // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                      // Send an email with this link
                      // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                      // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                      // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking &lt;a href=\"" + callbackUrl + "\"&gt;here&lt;/a&gt;");
  
                      return RedirectToAction("Index", "Home");
                  }
                  AddErrors(result);
              }
  
              // If we got this far, something failed, redisplay form
              return View(model);
          }
  </code></pre>
  
  <p>This is my IdentityModel in the class library</p>
  
  <pre><code>public class ApplicationUser : 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);
              // Add custom user claims here
              return userIdentity;
          }
      }
  
      public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
      {
          public virtual DbSet&lt;AspNetUsersExtendedDetails&gt; AspNetUsersExtendedDetails { get; set; }
          public virtual DbSet&lt;AspNetApplications&gt; AspNetApplications { get; set; }
          public virtual DbSet&lt;AspNetEventLogs&gt; AspNetEventLogs { get; set; }
          public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false)
          {
  
          }
          public static ApplicationDbContext Create()
          {
              return new ApplicationDbContext();
          }
      }
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>This is the error</p>
  
  <p><a href="https://i.stack.imgur.com/1PcQk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1PcQk.png" alt="enter image description here"></a></p>
  
  <h2>Edit 2</h2>
  
  <p>This is my connection string</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MSAPP-5cb5b1db-6c48-49c7-93b2-ba81ded39c1c;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MSAPP-5cb5b1db-6c48-49c7-93b2-ba81ded39c1c.mdf" providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
  </code></pre>