title: Custom Fields for IdentityUser
body: <p>I am trying to add custom fields for my IdentityUser. I have been through the documentation and also several articles that I've found online. I was able to figure out how to add custom fields, but I'm not sure how to set constraints on them. None of the articles I've found have covered this topic.</p>
  
  <pre><code>    // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
  public class ApplicationUser : IdentityUser
  {
      public DateTime RegistrationDate { get; set; }
  
      public string IPAddress { get; set; }
  
      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;
      }
  }
  </code></pre>
  
  <p>My code example is above. I have added 2 fields. RegistrationDate and IPAddress. I've used PowerShell to create the migrations and update the database.</p>
  
  <p>My questions are this:</p>
  
  <ol>
  <li>How do I set a default value for RegistrationDate? I wanted it to be SQL Now(). I can make the change in the database after the migration, but that gets my code and database out of sync.</li>
  <li>On IPAddress, I want to have the maximum size be 39 characters. When I update the database, the field is created as NVARCHAR(MAX) NULL. I want it to be NVARCHAR(39) NOT NULL. I can't see anyway to do that in the IdentityUser.</li>
  <li>Lastly, what if I wanted to store the IPAddress as VARBINARY or BINARY? That's not even a data type that C# will accept.</li>
  </ol>
  
  <p>I am able to go into the migration files and make some changes after creating the migration, but those changes are not reflected in the database. If I try to re-run Update-database from PowerShell, I get an error saying that there are no changes to update.</p>
  
  <p>On top of that. I don't know if I should be manually updating the migration files, since they are generated code.</p>
  
  <pre><code>    public partial class IPAddress : DbMigration
  {
      public override void Up()
      {
          AddColumn("dbo.AspNetUsers", "IPAddress", c =&gt; c.String(nullable: false, maxLength: 39));
      }
  
      public override void Down()
      {
          DropColumn("dbo.AspNetUsers", "IPAddress");
      }
  }
  </code></pre>
  
  <p>I'm using Visual Studio 2015 and version 4.6.</p>
  
  <p>Thanks</p>