title: Npgsql, error during saving a DateTime value (null value in column "CreatedAt" violates not-null constraint)
body: <p>I have the following model: </p>
  
  <pre><code>public class Product
  {
      public int Id { get; set; }
  
      public string Name { get; set; }
  
      public string Description { get; set; }
  
      public string Category { get; set; }
  
      public decimal Price { get; set; }
  
      [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
      [ScaffoldColumn(false)]
      public DateTime CreatedAt { get; set; } = DateTime.Now;
  }
  </code></pre>
  
  <p>And the following application context: </p>
  
  <pre><code>public class ApplicationContext : DbContext
  {
      private readonly string _connectionString;
  
      public DbSet&lt;Product&gt; Products { get; set; }
  
      public ApplicationContext(IConfiguration configuration)
      {
          _connectionString = configuration.GetConnectionString("Sportshop");
      }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          optionsBuilder.UseNpgsql(_connectionString, b =&gt; b.MigrationsAssembly("Web"));
      }
  }
  </code></pre>
  
  <p>Next I will show you a screen of my PostgreSQL data base schema:</p>
  
  <p><a href="https://i.stack.imgur.com/vDu1b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vDu1b.png" alt="enter image description here"></a></p>
  
  <p>I'm trying to save a new entity with the help of the next code:</p>
  
  <pre><code>    public ViewResult Index()
      {
          Product product = new Product
          {
              Name = "P1",
              Category = "test",
              Price = 1000,
              Description = "Hello !!!"
          };
  
          _applicationContext.Products.Add(product);
          _applicationContext.SaveChanges();
  
  
          return View(// ... some view data);
      }
  </code></pre>
  
  <p>But as the result I see this error. I don't understand why.</p>
  
  <p><a href="https://i.stack.imgur.com/eGkcq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eGkcq.png" alt="enter image description here"></a></p>
  
  <p>I absolutely sure that <code>CreatedAt</code>field is not null during the saving. See a screen of debug:</p>
  
  <p><a href="https://i.stack.imgur.com/Vvkpm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vvkpm.png" alt="enter image description here"></a></p>
  
  <p>Where is the mistake? </p>