Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to set unique constraint from EF core

protected override void OnModelCreating(ModelBuilder builder)
{
    builder.Entity<User>()
        .HasIndex(u => u.Email)
        .IsUnique();
}
Source by entityframeworkcore.com #
 
PREVIOUS NEXT
Tagged: #set #unique #constraint #EF #core
ADD COMMENT
Topic
Name
5+5 =