1 to 1, 1 to Many and Many to Many Relationships with EFCore in 2023

preview_player
Показать описание
In this video we'll use entity framework to set up 1 to 1, 1 to Many, and Many to Many relationships using a code first approach. The example project is an API for a blogging platform.

#dotnet #dotnetprogramming #dotnet6 #programming #csharp #programmingforbeginners #csharp #csharptutorial #csharpdotnet #aspnetcore #programmingtutorials #entityframework #entityframeworkcore #sqlserver #sql #sqlite #sqlforbeginners #database #sqldatabase #sqlservertutorial #codefirst #1to1 #onetoone #1tomany #onetomany #manytomany #codefirst

▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 - Introduction
0:24 - About the example project
0:40 - Creating the Blog entity
1:26 - 1 to 1 relationships
3:41 - Add migration, view changes in the database
4:16 - 1 to Many relationship
5:16 - Add migration, view changes in the database
5:30 - Many to Many relationship
6:20 - Add migration, view changes in the database

Start here if you've never used Entity Framework before:

Before Source Code:

After Source Code:

Database Diagram:

What is a Navigation Property?

Microsoft Docs on Entity Framework

Useful Entity Framework Commands:
1. Add a Migration
add-migration migrationName -verbose

2. Apply migrations to database:
update-database

3. Remove the most recent migration:
remove-migration

4. Get SQL Script for a Migration (will write file to project folder):

5. Move database back to a previous migration:
update-database previousMigrationName
Рекомендации по теме
Комментарии
Автор

By far the best explanation, I've been looking everywhere for something this clear, thank you, subscribed

gabrielgrigore
Автор

Definitely the best explanation I have found. Thank you! Looking forward to more videos on this topic.

ImmoTheBest
Автор

He is human guys... This is the human explanation of relationships for c# dev.. straight to the 4king point.. ayy.. big ups tho

fgkbnhs
Автор

At last getting my head around this. Thanks!

steveb
Автор

Thank you again! please continue with the videos please please!!

juliolp
Автор

Very helpful and easy explained! Thanks!

teto
Автор

Great video! Looking forward to the next one

ediblenecklace
Автор

Keep going man. Nice video, very informative.

piotrjakis
Автор

Hi, just wanted to encourage you to keep making videos like that, it is a great content and I belive if you will continue on you will succeed :)

kotto
Автор

What if I need store extra information in the Image and Blog relationship table ?

paollarce
Автор

May you please show the database diagram? just to see if it shows the 1 to 1 relationship

followerofchrist
Автор

Aren't we supposed to create a separate table for many to many relationship?

nokibulislam