I'm trying to use Entity Framework and face a problem of mismatching types in database with my models.
Specifically I have String field Date in class and date in SQL Server database. Due to that I have an error about improper type when loading data into model.
I attached some of my code, were I suppose casting can be applied.
public class MovementMap : EntityTypeConfiguration<Movement>
{
public MovementMap()
{
ToTable("viewMovement", "met");
HasKey(e => e.IdMovement);
Property(r => r.DateMovement).HasColumnName("dateMovement");
//Type of DateMovement - String, but column dateMovement in db has type date.
}
}
How can I convert it when loading or whenever? Would be glad to receive any ideas!
DateTimeif you can. If not, check outDateTime.ParseandDateTime.ParseExact.horses for courses