I am using an EF in the project with the configuration file. I have an employee's domain class which only has its assets (no data annotation or no relation)
I want to write a unique key restriction code for the user name.
Please see below, Employee Class
Public Sector Staff: IERTITI (Public Ent ID); Set; } Public string first name {receives; Set; } Public String LastName {get; Set; } Public string gender {receipt; Set; } Public string address {get; Set; } Public string MobileNo {get; Set; } Public String Email {get; Set; } Public String Username {get; Set; } Public string password {get; Set; }}
I have a configuration class, which includes all the assumptions of the staff member.
Data Anti Using model configuration; Class configuration {public class employee conferencing: entity type configuration & lt; Employee & gt; {Public Employee Convention () Property (x = & gt; x.FirstName). mandatory (). Hasmaxleamth (50); this. Property (x = & gt; x.ListName) .masmaxlemth (50); // I want to write the code for unique key constraints for the URL's property. I}}}
How do I write a unique key barrier for the property of the user name?
Please try this code
System.ComponentModel.DataAnnotations use. Schema; Using System.Data.Entity.Infrastructure.Annotations; ... this. Property (T = & gt; T. Usernam). Column annotation (index annotation.NotationName, new index annotation (new index attitudes ("IX_username", 1) {iicune = true});
Edit: Added by using the statement
Comments
Post a Comment