This project has moved and is read-only. For the latest updates, please go here.

Support for Date type column in code first

Jan 30, 2013 at 12:26 PM

If a column is defined as DATE type on a entity does Effort support this ?

If not is there a workaround ?

 

Thanks

Jan 30, 2013 at 1:26 PM
Edited Jan 30, 2013 at 1:36 PM

Hello,

Thank you for your feedback. I will consider adding type "date" to the provider manifest.

For now, I suggest you to set the specialized data column types with the DbModelBuilder.

public class MyContext : DbContext
{
    private bool test;

    public MyContext(DbConnection connection)
        : this(connection, false)
    {
    }

    public MyContext(DbConnection connection, bool test)
        : base(connection, true)
    {
        this.test= test;
    }

    public IDbSet<Thing> Things { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        if (!this.test)
        { 
            modelBuilder.Entity<Thing>().Property(t => t.Date).HasColumnType("date");
        }

        base.OnModelCreating(modelBuilder);
    }
}

Hope this helps!

Jan 30, 2013 at 1:35 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.