Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

entityframework index

// before 
modelBuilder.Entity<Person>()
        .Property(e => e.Name)
        .HasColumnAnnotation(
            IndexAnnotation.AnnotationName, 
            new IndexAnnotation(new IndexAttribute { IsUnique = true }));

// after
modelBuilder.Entity<Person>()
    .HasIndex(p => p.Name)
    .IsUnique();

// multi column index
modelBuilder.Entity<Person>()
    .HasIndex(p => new { p.Name, p.Firstname })
    .IsUnique();
Comment

PREVIOUS NEXT
Code Example
Csharp :: camera in raylib c# 
Csharp :: uwp roaming data sample 
Csharp :: JavaScriptSerializer() and convert to base64 
Csharp :: example of List c# 
Csharp :: query parameters sending to controller action asp.net core 
Csharp :: how to use monitor from system.threading in c# 
Csharp :: asp net core dependency injection factory with parameters 
Csharp :: generate a dropdown list from array data using razor .net mvc 
Csharp :: boxing and unboxing in c# 
Csharp :: c# check if string contains character multiple times 
Csharp :: serilog asp.net 5 
Csharp :: console writeline 
Csharp :: base c# 
Csharp :: escape chars for regex c# 
Csharp :: show datatable c# 
Csharp :: except method c# 
Csharp :: elasticsearch nested aggregation in c# 
Csharp :: c# yield return ienumerable 
Csharp :: implicit vs explicit cast c# 
Csharp :: add one to one relationship entity framework 
Csharp :: assert throw 
Csharp :: how to create a string in c# 
Csharp :: Entity framwork update parent entity added new sub entity 
Csharp :: why does everything reset when switching scene unity 
Csharp :: .net 3.1 bind json config 
Csharp :: Calculate relative time in C# 
Csharp :: deleting an item from a vector c# 
Csharp :: HOW TO CALL AN EXTENSION METHOD FOR VIEW C# 
Csharp :: C# Action Delegate 
Csharp :: Include multiple siblings at the Level 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =