Skip to content

The sample is written using Entity Framework and illustrates how to implement a many-to-many table relationship. The tools used were Visual Studio 2019 16.8.4 and .NET 5.0 Core

Notifications You must be signed in to change notification settings

kevin-weir/EFCoreManyToManyDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Many To Many Table Mapping

The sample is written using Entity Framework and illustrates how to implement a many-to-many table relationship. The tools used were Visual Studio 2019 16.8.4 and .NET 5.0 Core

Nuget Packages Used

Microsoft.EntityFrameworkCore.SqlServer

Microsoft.EntityFrameworkCore.Tools

Setup Datbase

To setup the database run the following command from the Nuget Package Manager Console:

Update-Database

Note:

A SQL Server localdb file will be created and will contain the tables used by this example.

Also the following logic was added to the web.api startup to properly handle the recursive nature of the many to many relationship.

    services.AddControllers()
        .AddJsonOptions(options => options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve);

About

The sample is written using Entity Framework and illustrates how to implement a many-to-many table relationship. The tools used were Visual Studio 2019 16.8.4 and .NET 5.0 Core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages