C# – Entity Framework Code First CTP4 Default Column Values

cctp4entityentity-framework-4

I have been looking into Code First with Entity Framework CTP4 and you can use the ModelBuilder to build up your table columns. Is there a way to set the default value for a column in the database using the ModelBuilder or some other mechanism?

Thank You!

Best Answer

I am using the constructor to set the default values. Never failed me

public class Activity
{
    [Required]
    public DateTime AddedDate { get; set; }

    public Activity()
    {
        AddedDate = DateTime.Now;
    }
}