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

 

相关文章: