I am using Entity Framework Code First method to create my database table. The following code
creates a DATETIME column in the database, but I want to create a
If you prefer not to decorate your classes with attributes, you can set this up in the DbContext's OnModelCreating like this:
public class DatabaseContext: DbContext
{
// DbSet's
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// magic starts
modelBuilder.Entity()
.Property(e => e.ReportDate)
.HasColumnType("date");
// magic ends
// ... other bindings
}
}