Entity Framework handles mysql,oracle concurrency problems

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.