I am making a resgistration form in ASP.NET Core and this is how my table schema looks enter image description here
The idCreatedTime field is a datetime field and has default value set to getdate(). When a user submits the registration form, where I am only asking for his username, emailId and password as the other two fields are auto value fields,I get this error
SqlException: Cannot insert the value NULL into column 'idCreatedTime', table 'PoliticalData.dbo.UserData'; column does not allow nulls. INSERT fails. The statement has been terminated.
Registration form
@page
@model IndianPoliticalData.Pages.UserCredentials.RegisterModel
<div>
    <form method="post">        
        <label>Enter Username</label>
        <input type="text" name="username" asp-for="UserData.Username" placeholder="Enter Username"/>
        <label>Enter EmailId</label>
        <input type="email" name="EmailId" asp-for="UserData.EmailId" placeholder="Enter Email"/>
        <label>Enter Password</label>
        <input type="password" name="password" asp-for="UserData.Password" placeholder="Enter Password" />
        <button type="submit">Register</button>
    </form>
</div>
Code that inserts data to the db
public async Task<IActionResult> OnPost()
{
    if (ModelState.IsValid)
    {
        await _context.UserData.AddAsync(UserData);
        await _context.SaveChangesAsync();
        return RedirectToPage("Index");
    }
    else
    {
        return Page();
    }
}
Just sharing the required columns
[Column("password")]
[StringLength(50)]
[Unicode(false)]
public string Password { get; set; } = null!;
        
[Column("emailId")]
[StringLength(50)]
[Unicode(false)]
public string EmailId { get; set; } = null!;
// Just added DateTime.UtcNow to check if that works.
[Column("idCreatedTime", TypeName = "datetime")]
public DateTime? IdCreatedTime { get; set; } = DateTime.UtcNow;
[InverseProperty("User")]
public virtual ICollection<Bookmark> Bookmarks { get; set; }
 
     
     
    