Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

ef core add OnModelCreating foreign key

public override void OnModelCreating(...)
{
    modelBuilder.Entity<Position>()
         // a position has zero or more Employees via property Employees
         .HasMany(position => position.Employees)
         // every Employee has exactly one Position
         .WithRequired(employee => employee.Position)
         // using foreign key Position_id
         .HasForeignKey(employee => employee.Position_Id);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# datetime 
Csharp :: c# WriteLine() 
Csharp :: linq select 
Csharp :: docker-compose cassandra db 
Csharp :: dotnet create web api 
Csharp :: c# console.writeline 
Csharp :: c# switch example 
Csharp :: c# if else 
Csharp :: reference to gameobject in different scene unity 
Csharp :: Transpose Matrix CSharp 
Csharp :: array to object c# 
Csharp :: c# copy an object 
Csharp :: binary tree c# 
Csharp :: one line condition c# 
Csharp :: wpf dispatcher timer is inaccurate 
Csharp :: void on TriggerCollisionEnter2D 
Csharp :: unity fast sin 
Csharp :: Archivarskodex freischalten 
Csharp :: C# Datagridview Column Header Double Click 
Csharp :: print bitmap company logo c sharp 
Csharp :: how to change argument of function in f# 
Csharp :: actual vector3 object unity 
Csharp :: executesqlinterpolatedasync stored procedure 
Csharp :: how to populate a collection c# 
Csharp :: asp:button onclick not respond 
Csharp :: Microsoft.ACE.OLEDB.12.0 c# excel first sheet 
Csharp :: c# remove duplicate cards 
Csharp :: asserting exceptions c# 
Csharp :: convert iqueryable to list c# 
Csharp :: c# task call more web api in parallel 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =