title: System.Data.SqlClient.SqlException: 'Invalid column name 'ApplicationRoleId'.'
body: <p>I'm working on my project it's based on ASP.net Core 2.0. I've created <code>ApplicationRole</code> and <code>ApplicationUser</code> class. I've wrote a snippet code for making roles when I run my project I've got this error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: 'Invalid column name
    'ApplicationRoleId'.</p>
  </blockquote>
  
  <p>But the same code that I use in ASP.net Core 1.1 didn't have any problem.</p>
  
  <p>I think it has a problem with this line of code:</p>
  
  <blockquote>
    <p><code>lineNumberOfUsers =  r.Users.Count</code></p>
  </blockquote>
  
  <p>Because when I comment this code project works fine, but <em>I need count of users for every role.</em></p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>public class ApplicationRoleController : Controller
  {
      private readonly UserManager&lt;ApplicationUser&gt; _userManager;
      private readonly RoleManager&lt;ApplicationRole&gt; _roleManager;
  
      public ApplicationRoleController(UserManager&lt;ApplicationUser&gt; userManager, RoleManager&lt;ApplicationRole&gt; roleManager)
      {
          _userManager = userManager;
          _roleManager = roleManager;
      }
  
      public IActionResult Index()
      {    
          List&lt;ApplicationRoleViewModel&gt; models = new List&lt;ApplicationRoleViewModel&gt;();
          models = _roleManager.Roles.Select(r =&gt; new ApplicationRoleViewModel
          {
  
              Id = r.Id,
              Name = r.Name,
              Description = r.Description,
              NumberOfUsers =  r.Users.Count 
          }).ToList();
          return View(models);
      }
  }
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code>public class ApplicationRole : IdentityRole
  {
      public string Description { get; set; }
      public virtual ICollection&lt;ApplicationUser&gt; Users { get; } = new List&lt;ApplicationUser&gt;(); 
  }
  </code></pre>
  
  <p>I've checked sql query in sql server profiler. when i ran sql query in sql server I got the same error.</p>
  
  <blockquote>
    <p>Invalid column name 'ApplicationRoleId'.</p>
  </blockquote>
  
  <pre><code>SELECT [r].[Id], [r].[Name], [r].[Description], (
      SELECT COUNT(*)
      FROM [AspNetUsers] AS [a]
      WHERE [r].[Id] = [a].[ApplicationRoleId]
  ) AS [NumberOfUsers]
  FROM [AspNetRoles] AS [r]
  </code></pre>