title: How to pass Null value to datetime in ASP.Net Identity User Table?
body: <p>I've already created my new custom fields inside identity user table since asp.net identity doesn't have all the fields like "Last Login Date", "Registration Date" and "Profile Update Date".</p>
  
  <p>During account register I'm getting an error message about the datetime2 is out of range. All of the 3 date fields are datetime type and set to "Allow Null". During this process I only need to set the date for "Registration Date" and the rest should be untouched but I don't how I can do this?</p>
  
  <p>This error is coming from "Last Login Date" and "Profile Update Date".</p>
  
  <h2>Create User Function</h2>
  
  <pre><code>namespace Web_WebApp.Account
  {
      public partial class Register : Page
      {
          protected void CreateUser_Click(object sender, EventArgs e)
          {
  
              var manager = Context.GetOwinContext().GetUserManager&lt;ApplicationUserManager&gt;();
              var signInManager = Context.GetOwinContext().Get&lt;ApplicationSignInManager&gt;();
              var user = new ApplicationUser() { UserName = UserName.Text, Email = Email.Text, FirstName = FirstName.Text, MiddleName = MiddleName.Text, LastName = LastName.Text, RegistrationDate = DateTime.Now };
              IdentityResult result = manager.Create(user, Password.Text );
  
              if (result.Succeeded)
              {
                  // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                  //string code = manager.GenerateEmailConfirmationToken(user.Id);
                  //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
                  //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking &lt;a href=\"" + callbackUrl + "\"&gt;here&lt;/a&gt;.");
  
                  signInManager.SignIn( user, isPersistent: false, rememberBrowser: false);
                  IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
              }
              else 
              {
                  ErrorMessage.Text = result.Errors.FirstOrDefault();
              }
          }
      }
  }
  </code></pre>
  
  <h2>Migration File</h2>
  
  <pre><code>   namespace Web_WebApp.Migrations
      {
          using System;
          using System.Data.Entity.Migrations;
  
          public partial class NewDateFields : DbMigration
          {
              public override void Up()
              {
                  AddColumn("dbo.User", "LastLoginDate", c =&gt; c.DateTime(nullable: true));
                  AddColumn("dbo.User", "RegistrationDate", c =&gt; c.DateTime(nullable: true));
                  AddColumn("dbo.User", "ProfileUpdateDate", c =&gt; c.DateTime(nullable: true));
              }
  
              public override void Down()
              {
                  DropColumn("dbo.User", "ProfileUpdateDate");
                  DropColumn("dbo.User", "RegistrationDate");
                  DropColumn("dbo.User", "LastLoginDate");
              }
          }
      }
  </code></pre>
  
  <h2>Error Message</h2>
  
  <pre><code>The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
  The statement has been terminated. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
   Exception Details: System.Data.SqlClient.SqlException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
  The statement has been terminated.
  </code></pre>
  
  <p>I appreciate your efforts in reaching a solution for my problem.</p>