首页 > 代码库 > EF唯一索引

EF唯一索引

this.Property(p => p.Name)                .IsRequired()                .HasMaxLength(new int?(50))                .HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("UX_Role_Name") { IsUnique=true}));
using System.ComponentModel.DataAnnotations.Schema;[Index(IsUnique = true)]

 

EF唯一索引