0

I am using a MySQL .NET Connector and when I insert a record into a database, it takes the .NET DateTime and complains that it can't convert from .NET DateTime to MySQL DateTime. Is there a way I can have the entity framework not update this field?

Do I just remove it from the entity model or is there a property I can set on it?

I have tried Convert Zero Datetime=True & Allow Zero Datetime=True in the connection string, but this just inserts 0000-00-00 00:00:00:00 when I do an insert.

I have tried explicitly setting the Datetime via Convert.ToDateTime(updateDT.ToString("yyyy-MM-dd hh:mm:ss"));, but this does not work and I don't want to have it to explicitly set the datetime for every object that has a DateTime field. I want the database to take care of setting the date for me on inserts or updates.

Xaisoft
  • 45,655
  • 87
  • 279
  • 432
  • Are you looking for [NotMapped](http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.notmappedattribute.aspx)? – Davin Tryon May 13 '13 at 21:36
  • @DavinTryon - I am using .NET 3.5 – Xaisoft May 13 '13 at 21:37
  • Ah. Would you rather not save the date, or find a way to update it? [This Question](http://stackoverflow.com/questions/1902523/entity-framework-mysql-datetime-format-issue) might help map the date. – Davin Tryon May 13 '13 at 21:42
  • @DavinTryon - I tried that question. If I do that, it saves nothing. I want to save a date, but I don't want to have to explicitly give it a value for each entity that has it. – Xaisoft May 13 '13 at 21:43
  • Dang, can it really be that hard! My initial thought was to change the SSDL, but I was trying to find another way. Seems there might not be one. http://stackoverflow.com/questions/737520/entity-framework-ignore-columns – Davin Tryon May 13 '13 at 21:50

0 Answers0