How to map a TIME-type column in Entity Framework 6?

5

I'm using this mapping for a DATETIME field of SQL Server:

Property(X => X.DatNascimento).HasColumnName("DAT_NASCIMENTO").HasColumnType("datetime");

But I have another TIME field that I do not know how to configure:

Property(X => X.HoraLimiteInferiorEntrada).HasColumnName("HORA_LIM_INF_ENTRADA").HasColumnType(??????);
    
asked by anonymous 05.06.2015 / 15:45

1 answer

5

The type is TimeSpan . Just make sure that you use at least SQL Server 2008, which is the first version of SQL Server that supports the type time :

public TimeSpan IntervaloMaximoAlmoco { get; set; }

For Fluent API , use:

Property(X => X.IntervaloMaximoAlmoco).HasColumnName("HOR_INT_ALMOCO").HasColumnType("time");
    
05.06.2015 / 15:54