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)]

 

[ForeignKey(nameof(SchoolId))]

 

posted @ 2016-09-21 21:20  shiningrise  阅读(734)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css