0

So guys i have this table created with entity framework (BlogPost Table)

 public class BlogPost
{

    public Guid Id { get; set; }
    public string Heading { get; set; }
    public string PageTitle { get; set; }
    public string Content { get; set; }
    public string  FeaturedImageUrl { get; set; }
    public string  ShortDescription { get; set; }
    public string UrlHandle { get; set; }
    public DateTime PublishDate { get; set; }
    public string Author { get; set; }
    public bool Visible { get; set; }

}

But if someone creates a blog post without filling the field DateTime in my database i get a default date time like this : 1/1/0001 12:00:00 AM

But i would like to get the present DateTime

so i tried changing the property to

   public DateTime PublishDate { get; set; } = DateTime.Now;

and add-migration , update-database.

but seems that nothing changed...

i can set the property everytime when i get a post request to DateTime.Now but i would like a more efecient way so database has a default DateTime.Now

nick glav
  • 39
  • 8

0 Answers0