0

I have problem with creating column in EntityFamework with Time type I am able to create columns with types like : string, int, DateTime without problems.

But how to create column with Time type?

public class OrdinacniHodiny : ValidityEntity<long>
{
     [Required]
     //[Required, DisplayFormat(DataFormatString = "{hh:mm}")]
     public Time CasOd { get; set; }
     /// <summary>
     /// Required
     /// 
     /// formát hh:mm
     /// </summary>

     [Required]
     public DateTime CasDo { get; set; }
}
TanvirArjel
  • 30,049
  • 14
  • 78
  • 114
Bobek
  • 757
  • 3
  • 7
  • 15
  • 2
    Possible duplicate of [SQL 'time' type in Entity Framework Code First](https://stackoverflow.com/questions/12186044/sql-time-type-in-entity-framework-code-first) – Gianlucca Sep 26 '18 at 12:10
  • Do you actually need Time type in Sql or do you just want to store a time – TheGeneral Sep 26 '18 at 12:10
  • I need something which is similar to DateTime, but without date. Only Time – Bobek Sep 26 '18 at 12:13

1 Answers1

0

Write your CasOd property as follows:

[Required]
public TimeSpan CasOd { get; set; }
TanvirArjel
  • 30,049
  • 14
  • 78
  • 114
  • You are right, I have tried this earlier, but didnt work becouse I had problem in database. – Bobek Sep 27 '18 at 05:22