Data Annotation Properties--timestamp Properties "Code-first series"

Source: Internet
Author: User

The timestamp attribute can be applied to the domain class, with only one byte array property above, this attribute, which sets the Tiemstamp type for the column. In a concurrent check, Code-first automatically uses this timestamp type of field.

Let's take a look at the code below:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel.DataAnnotations;usingSystem.ComponentModel.DataAnnotations.Schema;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceef2{[Table ("Studentinfo")]    Public classStudent {[Key] [Column (Order=1)]         Public intStudentKey1 {Get;Set; }        [Key] [Column (Order=2)]         Public intStudentKey2 {Get;Set; } [Column ("Name", typename="ntext")] [MaxLength ( -)]         Public stringStudentname {Get;Set; } [Notmapped ()] Public int? Age {Get;Set; }  Public intStdId {Get;Set; } [ForeignKey ("StdId")]         Public VirtualStandard Standard {Get;Set; } 1540644940 Public byte[] RowVersion {get; set; } }}

To run the program, the resulting database is:

Data Annotation Properties--timestamp Properties "Code-first series"

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.