Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# .net core entity framework one to many

protected override void OnModelCreating(Modelbuilder modelBuilder)
{
    modelBuilder.Entity<Employee>()
        .HasOne(e => e.Company)
        .WithMany(c => c.Employees);
}
Comment

c# .net core entity framework one to many

protected override void OnModelCreating(Modelbuilder modelBuilder)
{
    modelBuilder.Entity<Company>()
        .HasMany(c => c.Employees)
        .WithOne(e => e.Company);
}
Comment

c# .net core entity framework one to many

public class Company
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<Employee> Employees { get; set; }
}
public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
    public Company Company { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# loop through queue 
Csharp :: asp.net c# get user email address from AD 
Csharp :: unity mouse button names 
Csharp :: unity get distance between line and point 
Csharp :: how to call an If statement only once in C# 
Csharp :: how to get length of okobjectresult c# 
Csharp :: c# asp.net hover tooltip 
Csharp :: how to find the biggest number in c# 
Csharp :: trhow exception if is null c# 
Csharp :: vb.net delete folder if exists 
Csharp :: c# max sequence contains no elements 
Csharp :: Test for even Number 
Csharp :: .net core copy file in folder to root 
Csharp :: c# decimal to fixed 2 
Csharp :: c# float min value 
Csharp :: select top 5 in linq c# 
Csharp :: commit help 
Csharp :: dotnet core encryption and decryption 
Csharp :: ssis sql query in script task 
Csharp :: narcissistic 
Csharp :: c# multiple exceptions same handler 
Csharp :: c# square symbol 
Csharp :: asp.net web forms 
Csharp :: lightbox 
Csharp :: Reporting Progress from Async Tasks c# 
Csharp :: csharp attributes as generics constraints 
Csharp :: dadar pincode 
Csharp :: How to cache database tables to prevent many database queries in Asp.net C# mvc 
Csharp :: unity transparent sprite 
Csharp :: c# return statement 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =