EF Migrations 4.3.1 - can't add DateTime column. RRS feed

  • Question

  • I have an existing model class. I've added a property to it:

    public DateTime LastUpdated { get; set; }

    When I run update-database -force -verbose I get:

    ALTER TABLE [MyTable] ADD [LastUpdated] [datetime] NOT NULL DEFAULT '0001-01-01T00:00:00.000'
    System.Data.SqlClient.SqlException (0x80131904): The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
    The statement has been terminated.

    I'm going to guess this relates to the implied default value being used in the generated SQL - it would appear to be complaining that the varchar it used to initialize things is data lost.

    Can this be fixed in 4.3? How can I work around this?

    Tuesday, June 5, 2012 10:15 PM


All replies