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 it appears that mysql does not accept row version byte arrays. any guidance on how to accomplish this

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

Popular Answer

First off, I believe that the property attributes are insufficient to establish the correct field type if you are utilizing automated migration.
The syntax that the EF provider should produce to construct an automatically generated/updated timestamp is shown here as https://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.html.

You could attempt two things after generating the proper field type:

-Designate a field as a timestamp.

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

I don't believe that EF requires a Timestamp field to be a byte[. Timestamp should only be used to denote a database-generated field and a field that is used for optimistic concurrency (i.e. update queries contains a where on the keys of the record to update and this field). However, EF frequently does not function as I believe it to.

-Mark the column as a field to use to check for optimistic concurrency exceptions and as one that was generated by the database.

[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