Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

The entity type has multiple properties with the [Key] attribute.

public class NorthwindContext : DbContext
{
     public NorthwindContext(DbContextOptions<NorthwindContext> options):base(options) { }

     public NorthwindContext() { }

     protected override void OnModelCreating(ModelBuilder builder)
     {
         builder.Entity<Relationship>().HasKey(table => new {
         table.FriendId, table.UserId
         });
     }
     public DbSet<Relationship> Relationships { get; set; }
     public DbSet<User> Users { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: get key value from object c# 
Csharp :: parent unity 
Csharp :: asp.net textarea disable resize 
Csharp :: csharp read input from console as array 
Csharp :: c# dictionary keys to list 
Csharp :: delete the particular line in files in c# 
Csharp :: qtablewidget add image 
Csharp :: c# load form 
Csharp :: top level statements c# 
Csharp :: c# webclient post file 
Csharp :: unity text custom color 
Csharp :: c# distinct array of objects by values 
Csharp :: c# file read 
Csharp :: unity how to destroy child 
Csharp :: checking if a list contains a value unity 
Csharp :: check property type of collection c# 
Csharp :: c# right function 
Csharp :: c# template 
Csharp :: dictionary to list c# 
Csharp :: trygetvalue dictionary c# example 
Csharp :: if set active == false 
Csharp :: how to skip bin/Debug/netcoreapp3.1/ on the reltaive path 
Csharp :: map user to ConnectionId SignalR 
Csharp :: compact in laravrl 
Csharp :: interpolate rotation unity3d 
Csharp :: group by unique c# 
Csharp :: c# ternary operator 
Csharp :: linq find object from id 
Csharp :: c# dictionary get key by value 
Csharp :: Failed to generate swagger file. Error dotnet swagger tofile --serializeasv2 --output 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =