Home > Software design >  Zeros at the end of DateTime
Zeros at the end of DateTime

Time:11-19

How to delete zeros after datetime via EntityFramework? when i add record to database it displays it with zeros at the end in my datebase enter image description here

I specified DisplayFormat but when adding migration my Up method is empty

 [Column("Birth date")]
        [DisplayFormat(DataFormatString = "{yyyy/MM/dd}")]
        public DateTime BirthDate { get; set; }

CodePudding user response:

Use the following

[Column(TypeName="Date")]
[Column("Birth date")]
        public DateTime BirthDate { get; set; }

Please read more here https://learn.microsoft.com/en-us/ef/core/modeling/entity-properties?tabs=data-annotations,without-nrt

  • Related