title: Accssing ASP.NET 5 / MVC6 Identity Custom Profile data properties
body: <p>I have made a sample web app named ShoppingList using the asp.net 5 web application template (Mvc6/MVC core/Asp.net-5). I wanted to extend the user profile with a custom field name DefaultListId.</p>
  
  <p>The ApplicationUser.cs:</p>
  
  <pre><code>namespace ShoppingList.Models
  {
      // Add profile data for application users by adding properties to the ApplicationUser class
      public class ApplicationUser : IdentityUser
      {
          public int DefaultListId { get; set; }
      }
  }
  </code></pre>
  
  <p>In the home controller I would like to access the data stored for this property. I tried:</p>
  
  <pre><code>namespace ShoppingList.Controllers
  {
      public class HomeController : Controller
      {
         private UserManager&lt;ApplicationUser&gt; userManager = new UserManager&lt;ApplicationUser&gt;(new UserStore&lt;ApplicationUser&gt;(new ApplicationDbContext()));
  
          public IActionResult Index()
          {
             var userId = User.GetUserId();
             ApplicationUser user = userManager.FindById(userId);
  
              ViewBag.UserId = userId;
              ViewBag.DefaultListId = user.DefaultListId;
  
              return View();
          }
      //other actions omitted for brevity
  </code></pre>
  
  <p>However I get the following errors:</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error CS7036  There is no argument given that corresponds to the
    required formal parameter 'optionsAccessor' of
    'UserManager.UserManager(IUserStore,
    IOptions, IPasswordHasher,
    IEnumerable>,
    IEnumerable>, ILookupNormalizer,
    IdentityErrorDescriber, IServiceProvider,
    ILogger>,
    IHttpContextAccessor)'    ShoppingList.DNX 4.5.1, ShoppingList.DNX Core
    5.0   C:\Users\OleKristian\Documents\Programmering\ShoppingList\src\ShoppingList\Controllers\HomeController.cs    15  Active</p>
  </blockquote>
  
  <p>And...</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error CS1061  'UserManager' does not contain a
    definition for 'FindById' and no extension method 'FindById' accepting
    a first argument of type 'UserManager' could be found
    (are you missing a using directive or an assembly
    reference?)   ShoppingList.DNX 4.5.1, ShoppingList.DNX Core
    5.0   C:\Users\OleKristian\Documents\Programmering\ShoppingList\src\ShoppingList\Controllers\HomeController.cs    20  Active</p>
  </blockquote>