Entity framework core migrations to create database using Code First approach in .net core

preview_player
Показать описание
Lost all views, all comments, all subscribers, in short codingFirday lost you and with no choice left had to create new Channel - please provide your support by subscribing to new channel CodingLocker, please find the link below.

Subscribe Coding Locker

codingFriday needs your support in retrieving all subscribers back at Coding Locker. See you all there at Coding Locker. Thanks

codingFriday needs your support in retrieving all subscribers back at Coding Locker. See you all there at Coding Locker. Thanks

This is the example of #codefirst approach that explains how to create a database using entity framework core #migration commands, it explains #DbContext class in #efcore how to enable the migration in visual studio
2019.

-------------------------------------------
Commands if latest version 3.1.4
dotnet ef migrations add InitialCreate --context YourContextName --project YourProjectName
dotnet ef Database Update --context YourContextName --project YourProjectName

3 Packages you need
Microsoft.EntityFrameworkCore 3.1.4
Microsoft.EntityFrameworkCore.Design 3.1.4
Microsoft.EntityFrameworkCore.Tools 3.1.4

And remove, PrivateAssets all - PrivateAssets from Design and tools as they are generated by default.
-------------------------------------------
Link to GitHub
--------------------------------------------

Requirement
Generate Database from models and they should have a relationship of the primary key and foreign key
Approaches for ef core migration
-------------------------------------------
To create the database using migrations in entity framework core there are 3 approaches are shared here.
1.Creation of database using ef core migration by running the application
2. Creation of Db by running the migration commands and using Data Annotations
3.Creation of Db by adding table configuration, explains DbContext EntityConfiguration.
-------------------------------------------
the migration commands to create the database in code first approach in ef core are -
add-migration 'nameofyourmigration'
update-database
-------------------------------------------
once you view this video you will have a clear understanding of
ef core code first migrations, code first approach in entity framework .net core, DbContext in entity framework core.

FOLLOW ME ON - Coding Friday
----------------------------------------------
Instagram CP Variyani
Linkedin Chandra Prakash Variyani
Facebook Chandra Prakash Variyani

Please subscribe if this video is helpful for you.
Рекомендации по теме
Комментарии
Автор

extremely comprehensive, covering all aspects of possible migration, thanks a lot.

auchucknorris
Автор

Great video, thanks for show every step and every library to install !!!!

cristiandecordoba
Автор

The video was great at showing all the different steps! I would simply add that you should give reduce your camera size or even remove it completely as it hides the content of your video

marc-andreviau
Автор

Great video, all three approaches worked.

vivekmishra
Автор

Great video ! Everything worked fast and nicely

danyelaristizabal
Автор

Very Helpfull tutorial keep up the good work

amadorjr.escanilla
Автор

Really Its a nice video and also very helpful for me . If you Come up with some LINQ operation in future then it will helpful. And Best thing in your video that many approaches you showed to all

kamalpradhan
Автор

very good one, next time say also explain why we need to follow these pattern/practices and provide documentation links, so other have detailed explaination.Thank you:)

venkateshuttur
Автор

Nice job.. please type the code this will more helpful and understanding...

jibrankhan
Автор

I get why you were talking fast, you saw it in your head, and rattled it off. I do the same thing. But we don't always hear as fast as one can think... lol. But yeah, GREAT video. I like that you touched on all three approaches. Do you have a Database First video as well?

capncrunch
Автор

Loved the video, is there anyway to auto populate the databases when migrating. Say you're adding new tables.

thecyberyak
Автор

it would have great if u explain the difference between the 2 nd and 3 rd approach . but still great class

bunnyworld
Автор

Thanks for a great one as all the comments say. :)

But I have one query if you can help me.
let say I am following approach 2.
and created the application, a web api (web service )

and after deploying it to web server How can I run - update-databasecommand ?

Thanks.

bhavikvaishnani
Автор

Nice video !! Is there a way to generate the migration script as an SQL file and execute it manually instead of directly applying the migrations to an existing Database ? Have earlier used the command 'update-database -script' in .NET framework for this purpose, but it seems to be not supported by .NET core. Any idea ? Thanks in advance.

basiljacob
Автор

I have an error when run Add-Migration
Error message is "The specified deps.json [D:\%^&*%^&*%&*\deps.json] does not exist"
I google that qusetion and didnt find solution..

lin
Автор

Do you have tutorial for Database first approach ?

rajeevtrivedi
Автор

Suppose instead of typing "add-migration developerdbMigration" we accidentally type "update-database developerdbMigration" and press the "Enter".... what will happen then?

lennonfernandes
Автор

can u teach us how to perform CRUD operation when there is a foreign key?

sukdipkar
Автор

in blazor i will get a null reference exception if i try to save something in the child class via the parent class example
Mother.child.Name="Hasad";

Spirittism
Автор

Bro how to implement soft delete in ef core code first approach

elangovanr