Answers for "entity framework core 5 add unique constraint with attribute"

C#
0

how to set unique constraint from EF core

protected override void OnModelCreating(ModelBuilder builder)
{
    builder.Entity<User>()
        .HasIndex(u => u.Email)
        .IsUnique();
}
Posted by: Guest on February-27-2020

Code answers related to "entity framework core 5 add unique constraint with attribute"

C# Answers by Framework

Browse Popular Code Answers by Language