title: ASP.NET Core Identity. Using ApplicationDbContext and UserManager. Do they share the context?
body: <p>i have an database initialization method in an ASP.NET MVC Core 2 application.
  In that method i'm using ApplicationDbContext and UserManager to initialize the database. 
  I get both instances from the constructor's dependency injection:</p>
  
  <pre><code>public static void Initialize(ApplicationDbContext context,
              UserManager&lt;ApplicationUser&gt; user)
  </code></pre>
  
  <p>What i want to know is if they share the same context instance or if one context is created for ApplicationDbContext and another for UserManager.
  If i execute something like this:</p>
  
  <pre><code>ApplicationUser adminTeacherUser = new ApplicationUser
              {
                  UserName = "test@test.com",
                  Email = "test@test.com",
                  EmailConfirmed = true,
                  Name = "test",
                  LastName = "test",
                  BirthDate = null,
                  EntryDate = DateTime.Now                    
              };
  
              userManager.CreateAsync(adminTeacherUser, "password").Wait();
  </code></pre>
  
  <p>The user is created at database inmediatly after the CreateAsync call.</p>
  
  <p>But, if then i update the user like this:</p>
  
  <pre><code>adminTeacherUser.Name = "other";                
  userManager.UpdateAsync(adminTeacherUser);
  </code></pre>
  
  <p>After the call to UpdateAsync nothing is updated at the database. The name of the user stills being "test".</p>
  
  <p>But, if then i execute:</p>
  
  <pre><code>context.SaveChanges();
  </code></pre>
  
  <p>The changes are applied and the database is updated.</p>
  
  <p>So, why the CreateAsync method "saves its changes" without explicitly calling "context.SaveChanges" and the UpdateAsync method needs it? Is the ApplicationDbContext instance i get by dependency injection the same that CreateAsync is using?</p>
  
  <p>Thank you.</p>