Entityframework-dbfirst-after re-generation of the Write verification disappears (workaround)

Source: Internet
Author: User

1. This is the class generated by EF:

namespacePMS. dataprovider.entityframework{usingSystem; usingSystem.Collections.Generic;  Public Partial classM_managers { Public stringUserName {Get;Set; }  Public stringNickname {Get;Set; }  Public stringPassWord {Get;Set; }  Public stringheadimg {Get;Set; }  Public intAge {Get;Set; }  Public BOOLIsmale {Get;Set; }  Public stringEmail {Get;Set; }  Public stringMobile {Get;Set; }  Public stringAddress {Get;Set; }  Public stringSignature {Get;Set; }  Public stringRoles {Get;Set; }  Public stringDescription {Get;Set; }  PublicSystem.DateTime CreateDate {Get;Set; }  Public stringCreateUser {Get;Set; }  PublicSystem.DateTime Lastlogindate {Get;Set; }  Public intLogintimes {Get;Set; } }}

2. Create a new part (partial) class:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel.DataAnnotations;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacePMS. dataprovider.entityframework{[Metadatatype (typeof(M_managersmetadata))]  Public Partial classm_managers {} Public classM_managersmetadata {[Display (Name="User name")] [Required (ErrorMessage="*")] [Stringlength ( -, errormessage ="the character length should be between 6-50", Minimumlength =6)]         Public stringUserName {Get;Set; } [Display (Name="Display Name")] [Required (ErrorMessage="*")] [Stringlength ( -, errormessage ="the character length should be between 6-50", Minimumlength =6)]         Public stringNickname {Get;Set; } [Display (Name="Password")] [Required (ErrorMessage="*")] [DataType (Datatype.password)] [Stringlength ( -, errormessage ="the character length should be between 6-50", Minimumlength =6)]         Public stringPassWord {Get;Set; } [Display (Name="Avatar")] [DataType (Datatype.imageurl)] Public stringheadimg {Get;Set; } [Display (Name="Age")] [Range (Ten, -, errormessage ="The age should be between 10-120")]         Public intAge {Get;Set; } [Display (Name="Sex")]         Public BOOLIsmale {Get;Set; } [Display (Name="Email")] [Required (ErrorMessage="*")] [DataType (datatype.emailaddress)] [EmailAddress (ErrorMessage="The mailbox format is not correct")] [Stringlength ( -, errormessage ="the character length should be between 6-50", Minimumlength =6)]         Public stringEmail {Get;Set; } [Display (Name="Mobile Phone")] [Required (ErrorMessage="*")]         Public stringMobile {Get;Set; } [Display (Name="Address")]         Public stringAddress {Get;Set; } [Display (Name="Signature")]         Public stringSignature {Get;Set; } [Display (Name="role")]         Public stringRoles {Get;Set; } [Display (Name="Description")] [DataType (datatype.multilinetext)] Public stringDescription {Get;Set; } [Display (Name="Date Created")] [DataType (Datatype.datetime, ErrorMessage="date format is incorrect")]         PublicSystem.DateTime CreateDate {Get;Set; } [Display (Name="Create Person")]         Public stringCreateUser {Get;Set; } [Display (Name="Last Login Date")] [DataType (Datatype.date, ErrorMessage="date format is incorrect")]         PublicSystem.DateTime Lastlogindate {Get;Set; } [Display (Name="Number of Logins")]         Public intLogintimes {Get;Set; } }}


Attention:

[Metadatatype (typeof(M_managersmetadata))]//Specifies the metadata class to be associated for the newly created partial class     Public Partial classM_managers//This is the new section class (Empty Inside, nothing written), and note that the class name and namespace are the same as those generated by EF    {    }     Public classM_managersmetadata//Create a new metadata class    {         //Write model validation here[Display (Name ="User name")] [Required (ErrorMessage="*")] [Stringlength ( -, errormessage ="the character length should be between 6-50", Minimumlength =6)]         Public stringUserName {Get;Set; } }

Entityframework-dbfirst-after re-generation of the Write verification disappears (workaround)

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.