entity framework 6 mysql rowversion

c# ef-code-first entity-framework entity-framework-6 mysql

Question

I am using entity framework 6 with my sql and seems like row version byte array is not supported by mysql. any help how this can be achieved.

[Column(TypeName = "timestamp")]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime TimeStamp { get; set; }
1
8
8/25/2015 1:05:52 PM

Popular Answer

First of all, if you are using automatic migration I think that the property attributes are not enough to create the right field type.
Here https://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.html there are the syntax that EF provider should generate to create a timestamp that is automatically generated/updated.

After creating the right field type you could do 2 tries:

-Mark the field as Timestamp

[Timestamp]
public DateTime TimeStamp { get; set; }

I don't think that EF needs that a Timestamp field is byte[]. Timestamp should only mean that is database generated field and that the optimistic concurrency use that field (i.e. update queries contains a where on the keys of the record to update and this field). But often EF does not work as I think...

-Mark the field as generated by database and as a field to use to check for optimistic concurrency exceptions

[ConcurrencyCheck]
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime TimeStamp { get; set; }
4
8/21/2015 7:03:00 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow