Premise, use the Entity Framework Power Tools to generate code First mode
Environment:
EF6.0
MySQL 6.9
EF Power Tools 4
VS2012
Problem, SQL Server uses TS field to handle concurrency control, how does MySQL handle it? How does Oracle handle it?
Idea: Use the concurrency control identity of EF plus the database to automatically update the TS field
1. The database automatically updates TS, MySQL can be set TS column Timestamp type, plus the default value
Not NULL DEFAULT current_timestamp on UPDATE current_timestamp
Oracle can only add one trigger to automatically update this TS
2. EF adds this TS field to the Modelmap class Isconcurrencytoken
This. Property (t = t.ts). Hascolumnname ("TS"). Isconcurrencytoken ()
3. Set up the TT template for EF Power Tools
Auto-increment Isconcurrencytoken method with attribute name as TS
OK, when you update the data now, using EFPROF to view the SQL data, you can see the addition of a Where condition of ts= ' 2015-1-8 010101 ' condition
Entity Framework handles mysql,oracle concurrency problems