Entity framework core migrations

  Рет қаралды 228,546

kudvenkat

kudvenkat

Күн бұрын

In this video we will discuss the concept of Migrations in Entity Framework Core.
Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
/ @aarvikitchen5572
Text version of the video
csharp-video-t...
Slides
csharp-video-t...
ASP.NET Core Text Articles & Slides
csharp-video-t...
ASP.NET Core Tutorial
• ASP.NET core tutorial ...
Angular, JavaScript, jQuery, Dot Net & SQL Playlists
www.youtube.co...
What is a migration in entity framework core
Migration is an entity framework core feature that keeps the database schema and our application model classes (also called entity class) in sync.
If you have not executed at-least the initial migration in your application you might get the following SqlException
SqlException: Cannot open database "EmployeeDB" requested by the login.
This is because we do not have the database created yet. One way to create the database is by
Creating a migration first and then
Executing that migration
To work with migrations, we can either use the Package Manager Console (PMC) or the .NET core command-line interface (CLI). If you are using Visual Studio like me, then use the Package Manager Console.
To launch Package Manager Console in Visual Studio, click on View - Other Windows - Package Manager Console
Common entity framework core migration commands
We will be using the following 3 common commands to work with migrations in entity framework core.
get-help about_entityframeworkcore - Provides entity framework core help
Add-Migration - Adds a new migration
Update-Database - Updates the database to a specified migration
Please note : You can use get-help command with any of the above commands. For example get-help Add-Migration provides help for Add-Migration command.
Creating Migration in Entity Framework Core
The following command creates the initial migration. InitialCreate is the name of the migration.
Add-Migration InitialCreate
When the above command completes, you will see a file in the "Migrations" folder that contains the name InitialCreate.cs. This file has the code required to create the respective database tables.
Please note : To have the command auto-completed in the Package Manager Console window, type part of the command and press the TAB key.
Update-Database in Entity Framework Core
We need to execute the migration code to create the tables. If the database does not exist already, it creates the database and then the database tables. For updating the database, we use Update-Database command. To the Update-Database command we may pass the migration name we want to execute. If no migration is specified, the command by default executes the last migration.
After the migration is executed, when you navigate to the application we no longer get the following SqlException
SqlException: Cannot open database "EmployeeDB" requested by the login.
This is because the EmployeeDB is created when the migration is executed. We can confirm this in SQL Server Object Explorer window in Visual Studio.
At the moment we do not have any data in the Employees table. In our next video, we will discuss how to seed the database table with initial data.

Пікірлер: 169
@naodagere8210
@naodagere8210 4 жыл бұрын
I am always amazed by the amount of time and energy you invest while preparing these materials.Still for free.Thank you so much.
@ПавелБываев
@ПавелБываев 5 жыл бұрын
I cant use Add-Migration before installed "Microsoft.EntityFrameworkCore.Tools" in PM console: Install-Package Microsoft.EntityFrameworkCore.Tools
@amey203
@amey203 5 жыл бұрын
thank u so much bro .it helped me
@erkangorgulu6013
@erkangorgulu6013 5 жыл бұрын
I knew i was missing a package but thinking what it could be. Much appreciated.
@amermagdy5440
@amermagdy5440 4 жыл бұрын
if there is any rollback try to specify the version by this command line Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.14 also for guarantee your needed version look in the warning
@jainamshah5681
@jainamshah5681 4 жыл бұрын
Helped me too. Thanks a lot.
@hexlatino3421
@hexlatino3421 4 жыл бұрын
Thank u. you saved me at least 1 hour of my time :)
@stephenriding6460
@stephenriding6460 5 жыл бұрын
Couldn't figure out for the life of me how to actually create the database. Didn't know about update-database. Thank you so much for this video!
@yasirirfan5262
@yasirirfan5262 9 ай бұрын
You are making great .NET Engineers. Be blessed.
@hzubaca
@hzubaca 4 жыл бұрын
simple, and straight to the point! Kudos!
@mohdsyazwiabhalim8122
@mohdsyazwiabhalim8122 2 ай бұрын
Best tutorial ever. Thanks!!
@hamedbakhtiari7540
@hamedbakhtiari7540 4 жыл бұрын
Thank you, so much , but in .net core 3 and newer version we should install EntityFrameworkCore.Tools and then use Add-Migration
@dipeshjadhav1546
@dipeshjadhav1546 4 жыл бұрын
Thanks Man ! Saved me some time
@rakeshpanigrahi577
@rakeshpanigrahi577 3 жыл бұрын
Thanks!
@honeesh1
@honeesh1 5 жыл бұрын
My teacher thank you very much Very useful lectures too Thank you from the depths
@vaibhavtrikolikar4902
@vaibhavtrikolikar4902 5 ай бұрын
Thank you Sir for another great video As usual:)
@talkathiriify
@talkathiriify 5 жыл бұрын
Thank you again for the excellent video Best regards
@عمربنعبدالعزيزمحمدصالح-ر1ض
@عمربنعبدالعزيزمحمدصالح-ر1ض 5 жыл бұрын
I have Error:Value cannot be null. Parameter name: connectionString
@Jayakrishna8
@Jayakrishna8 5 жыл бұрын
@@عمربنعبدالعزيزمحمدصالح-ر1ض make it connectionStrings
@zn6151
@zn6151 3 жыл бұрын
The explanation is amazing 👏
@ljupconewman9357
@ljupconewman9357 5 жыл бұрын
Eloquent and excellent. One thing though, after i added a migration and updated the database I can't see it in sql server. I tried by changing the connection string in several ways, but it didn't change anything. Maybe show this in your next video?
@saivaibhavmedavarapu7383
@saivaibhavmedavarapu7383 5 жыл бұрын
Can you send me the code of this project on vaibhav.medavarapu@gmail.com. It really helps me in catching up. Thanks
@menaf77
@menaf77 5 жыл бұрын
the same here too i can't see the database created in the sqlserver. pls share how you get it work
@bulldog2024
@bulldog2024 5 жыл бұрын
You might have to refresh the database and it should be there.
@neilsumanda1538
@neilsumanda1538 4 жыл бұрын
i always wonder how much effort the developers into this migration.. in practice, u dnt create a database from the ground-up, u work with an existing database with actual records.. or did i missed something here...?
@halivudestevez2
@halivudestevez2 4 жыл бұрын
it depends...
@mprto68
@mprto68 Жыл бұрын
I keep getting an error when migrating "unable to create an object of type 'dbcontext'."
@jaikialves3186
@jaikialves3186 3 жыл бұрын
Thank you, your video save me
@lin4469
@lin4469 3 жыл бұрын
I have an error... The specified deps.json [D:\GitFirstCode\OnlineShop\Shop.UI\Shop.UI.deps.json] does not exist
@bulldog2024
@bulldog2024 5 жыл бұрын
Thanks again for the great content.
@eugene-white-shark
@eugene-white-shark 3 жыл бұрын
Thank you very much!
@sinanukuslu5420
@sinanukuslu5420 5 жыл бұрын
Çok teşekkür ediyorum. Çok iyi anlatıyorsunuz.
@1eagleusa
@1eagleusa 5 жыл бұрын
Question about field creation, the filed for department is enum and is nullable, in the video it creates the filed in the table as integer and nullable if false. I think I understand the integer part but should it be nullable because the field is nullable? What if it was desired to have the field nullable how would it be accomplished to signify nullable field during migration? Thank you for all your hard work.
@coolwaterdvr
@coolwaterdvr 5 жыл бұрын
Thank you Venkat.
@00kiss00L
@00kiss00L 5 жыл бұрын
If you are using MacOS version of Visual Studio, you might stuck at this episode. You won't find SS Object Explorer nor Package Manager Console because none of those are supported. Here is what I did: 1. Install NuGet PowerShell Core Console: lastexitcode.com/blog/2019/05/05/NuGetPowerShellCoreConsoleVisualStudioForMac8-0/ 2. Install Entity Framework Core tools: docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell 3. Install SQL Server on Mac (Docker + Azure Data Studio): database.guide/how-to-install-sql-server-on-a-mac/ 4. Change the connection string to something like this: "Server=localhost;Database=sql_server_demo;User Id=sa;Password=ReallyStrongPwd123"
@sathyavenkatesh5047
@sathyavenkatesh5047 5 жыл бұрын
I think this Migration is only for Code First approach right and not for Database First approach ?
@leoniduvarov6565
@leoniduvarov6565 4 жыл бұрын
Very clear, thank you!
@halivudestevez2
@halivudestevez2 4 жыл бұрын
thank you, Sir, it's clear now! :)
@lifetraveler8008
@lifetraveler8008 4 жыл бұрын
I am getting the following error System.ArgumentNullException: 'Value cannot be null. (Parameter 'connectionString')' help please!! I found the problem The ConnectionStrings inthe appsetting.json had space in between the word Connection and string . It should be "ConnectionStrings" and not "Connection Strings"
@rashedalqadi3695
@rashedalqadi3695 4 жыл бұрын
stackoverflow.com/questions/40874640/value-cannot-be-null-parameter-name-connectionstring-appsettings-json-in-start there is some solution
@jrh383
@jrh383 3 жыл бұрын
Hola prof. este método de migraciones da terror, ya que si cuento con bases de datos de cientos de gb, no me convence que el programador tenga acceso a esto, ya que por una mala programación pueden borrar los datos, además existen especialistas en BD, por favor podrías indicar si tienes un enfoque base de datos primero. Y de veras muchas pero muchas gracias por dedicar tanto de tu tiempo y explicas perfectamente. nuevamente gracias.
@arpitmahyavanshi9282
@arpitmahyavanshi9282 Жыл бұрын
i dont have any data in the db so i have to put some data in it or it will be done automatically accordin to this video
@AllanMadsenDK
@AllanMadsenDK 5 жыл бұрын
Is it possible to use the PM to create and manage stored procedures? I have been told, that using stored procedures, is the safest way, to interact with the SQL database. Thank you for some very great toturials!!
@MmMm-tg5mq
@MmMm-tg5mq 5 жыл бұрын
very informative nice video thanks a lot
@TheHPure
@TheHPure 3 жыл бұрын
What about database first approach? I'm having really hard time figuring this out..
@henimex
@henimex 3 жыл бұрын
Thank you. Again
@Ty1er
@Ty1er 3 жыл бұрын
So far so gud
@xinjinli6442
@xinjinli6442 2 жыл бұрын
Really good material. But I have a question. When I have only schema updates, everything works okay. Now I have seed methods to add some records to the database.(For example menu items, rights, roles) And I tried to run add-migration whenever I have updates in schemas. It worked yet. But I wanted to add some more records. I mean I updated the seed methods. And then run add-migration update_seed. After that, update-database failed. Would you help me with how to handle the cases?
@Viktor_fff
@Viktor_fff Жыл бұрын
Thanks for help)
@AhmedGamalGIS
@AhmedGamalGIS 5 жыл бұрын
thanks alot My teacher need tutorial for unit test in asp.net core
@prithupaul5177
@prithupaul5177 4 жыл бұрын
Getting this exception while using "Add-Migration" command Method 'Create' in type 'Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlTranslatingExpressionVisitorFactory' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation. anyone can help?
@lennonfernandes1696
@lennonfernandes1696 2 жыл бұрын
I am getting "build failed" error while running the command "add-migration migrationName" Earlier I had accidentally typed "update-database migratonName" instead of "add-migration migrationName" and then got an error. From then on I am getting "build failed" error..
@coderggk6819
@coderggk6819 4 жыл бұрын
But 99% of projects does have existing Database. does it means this code first wont work?
@alwaseem5309
@alwaseem5309 5 жыл бұрын
Awesome !
@mohammadhilal8508
@mohammadhilal8508 4 жыл бұрын
While doing migration it gives an error deps. Json(path) does not exist.
@ymn76ymn
@ymn76ymn 3 жыл бұрын
thanks for you
@HarshRaj-pu4gi
@HarshRaj-pu4gi 4 жыл бұрын
I am getting error while trying to insert data saying "Cannot insert explicit value for identity column in table ' ' when IDENTITY_INSERT is set to OFF. Do anyone knows solution to this?
@gealglover2479
@gealglover2479 4 жыл бұрын
First thing I noticed is the table "Employees" will be built with field "Id" being an identity column. The migration shows .Annotation("SqlServer:Identity", "1, 1") while his tutorial shows .Annotation("SQLserver:ValueGenerationStrategy"). You should therefore not supply a value for the Id when inserting data.
@areensahu5299
@areensahu5299 4 жыл бұрын
I dont why I cant use Commands like Add-migration and Update Database. I have also tried installing Microsoft.Entityframeworkcore.tools NuGet package but it wont install. Please help.
@DecklonNyarko
@DecklonNyarko 5 жыл бұрын
Hiya, thanks for your hard-work very much appreciated. my project given me the error "There is already an object named 'AspNetRoles' in the database." when i tried to update database
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 5 жыл бұрын
Hello Decklon - That's a bit strange. These kind of errors usually happen if we manually create or change Identity tables without going through migrations.
@ypwygk652
@ypwygk652 4 жыл бұрын
i have this error, Method 'Create' in type 'Microsoft.EntityFrameworkCore.SqlServer.Query.Internal.SqlServerSqlTranslatingExpressionVisitorFactory' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=3.1.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
@TheSivac
@TheSivac 4 жыл бұрын
Any help for this error I get: "The entity type 'Pile' requires a primary key to be defined. If you intended to use a keyless entity type call 'HasNoKey()". I already tried putting the [Key] attribute above my PileId property... Didnt help
@kristiantomic234
@kristiantomic234 4 жыл бұрын
Did you solve it?
@RachitJain4U
@RachitJain4U 3 жыл бұрын
Thanks sir :)
@MuhammedAli-nu4tb
@MuhammedAli-nu4tb 5 жыл бұрын
"Format of the initialization string does not conform to specification starting at index 0." I get an error
@fermidu8811
@fermidu8811 4 жыл бұрын
How can I update a dbcontext if I´m using database first? I hava my database ready, just need to update de context on EFCore 3.1, any help please?
@InamiLanzhu
@InamiLanzhu 2 ай бұрын
Another wonderful lecture, thanks! 50/124
@arpansarkar7924
@arpansarkar7924 4 жыл бұрын
If you are getting error during add-migration Install Entity framework core package.
@jihedjaoidi4313
@jihedjaoidi4313 5 жыл бұрын
Plz I want buy à tutorial for unit test how I do that plz thank you
@VinuP2023
@VinuP2023 5 жыл бұрын
Venkat has a tutorial on Unit Testing in Udemy. Please find it
@ljupconewman9357
@ljupconewman9357 5 жыл бұрын
@@VinuP2023 does he have about other topics?
@التاريخ-ح4ظ
@التاريخ-ح4ظ 4 жыл бұрын
PlatformNotSupportedException: LocalDB is not supported on this platform. ??ubuntu
@kokaneehooman
@kokaneehooman 5 жыл бұрын
package manager console does not recognize the add-migration command. how do fix this?
@krishnakishore2889
@krishnakishore2889 5 жыл бұрын
in the package manager console run this command Install-Package Microsoft.EntityFrameworkCore.Tools
@OutNumbered41
@OutNumbered41 3 жыл бұрын
Every time I attempt to do this I get an error saying Could not load assembly ''. Ensure it is referenced by the startup project 'Entity'
@rayt6867
@rayt6867 5 жыл бұрын
So far so good, Excellent tutorial, Is the source code in Github or any other place to download it, so that I can compare with mine to keep the videos in sink? Thank you very much.
@hooiyan6040
@hooiyan6040 5 жыл бұрын
Hi! The souce code can be found on the blogspot. You can check them out at the description section under every videos. :)
@mdsaddamkhan8400
@mdsaddamkhan8400 4 жыл бұрын
i am getting this exception please help me ArgumentException: Invalid value for key 'integrated security'.
@PriyankaSoni2014
@PriyankaSoni2014 4 жыл бұрын
try Trusted_Connection=True instead of integrated security at EmployeeDBConnection in Appsetting.json file
@mdsaddamkhan8400
@mdsaddamkhan8400 4 жыл бұрын
@@PriyankaSoni2014 yup... I used the same I am getting different level of error right now
@Abhimanyukumar-vb8bz
@Abhimanyukumar-vb8bz 4 жыл бұрын
@@mdsaddamkhan8400 use -> integrated security= SSPI
@avitwito1734
@avitwito1734 5 жыл бұрын
How did it knew that the primary key should be ID? (table.PrimaryKey("PK_Employees", x => x.Id);)
@bulldog2024
@bulldog2024 5 жыл бұрын
I believe, by convention, Entityframework will automatically look for a field that contains the term 'Id' and make that the primary key unless you use the [Key] attribute.
@AndrewBarzyk
@AndrewBarzyk 5 жыл бұрын
I cannot get the migration to work. I ran it -v to get the error: Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type 'AppDbContext'. For the different patterns supported at design time, see go.microsoft.com/fwlink/?linkid=851728 ---> System.MissingMethodException: No parameterless constructor defined for type 'ConciergeApp.Models.AppDbContext'. at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) much Internet ink was spilled on removing the dbContext from Startup.cs and moving it to Program.cs... I know my connection string is ok (MYSQL) because when I create the database and tables columns manually my application runs. I am using the latest version of Visual Studio Community 2019. Has MS changed something again???
@AndrewBarzyk
@AndrewBarzyk 5 жыл бұрын
I got it working. I was using Visual Studio 2019. Apparently in true MS style, they released it without full support for a bunch of features.
@khoinguyen4400
@khoinguyen4400 5 жыл бұрын
How can I create a table within an existing schema when I run update-Database. Please help
@amermagdy5440
@amermagdy5440 4 жыл бұрын
if there is any rollback try to specify the version by this command line Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.1.14 also for guarantee your needed version look in the warning
@darkogele
@darkogele 5 жыл бұрын
Great job as always keep it up ill build you a Monument if i become rich :D
@MmMm-tg5mq
@MmMm-tg5mq 5 жыл бұрын
I think he didn't need your Monument , if you can help just donate at his blog
@argeltal9090
@argeltal9090 4 жыл бұрын
И јас го делам истото мислење за чоеков !
@arunnayak3342
@arunnayak3342 3 жыл бұрын
Please make a video on Response caching in .net core if possible
@SPRajOfficial
@SPRajOfficial 4 жыл бұрын
I want to create mysql db migrations code first? Can u guide?
@goldencourses645
@goldencourses645 3 жыл бұрын
Just Install this package mysql.entityframeworkcore5.0.0 instead of SQL.EntityFramework and do the same (connection string to your mysql db)
@meeramaahidoshi1207
@meeramaahidoshi1207 3 жыл бұрын
@@goldencourses645 can u suggest me the connection string to sql server connection as i am getting error in it what would be the connection string if we want to connect to sqlserver with sql server authentication "EmployeeDBConnection" : "server=(192.168.1.97,9905 )\\sa;database=EmployeeDB;Trusted_Connection=True" got confused. where the pwd and authentication to be entered
@amreenmujahed76
@amreenmujahed76 5 жыл бұрын
hello venkat sir please help me ,i m unable to update-database cammand in console package manager
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Same
@Rakesh_Bandaru
@Rakesh_Bandaru 4 жыл бұрын
MOdify connection string as "EmployeeDBConnection": "Server=.;Database=EmployeeDB;Trusted_Connection=true"
@ypwygk652
@ypwygk652 4 жыл бұрын
i have error Exception has been thrown by the target of an invocation.
@deepwoodsengineering3763
@deepwoodsengineering3763 5 жыл бұрын
Thank You
@sebastianph4378
@sebastianph4378 5 жыл бұрын
how can I resolve this error in the package manager console, "Unable to create an object of type 'appDbContext'. For the different patterns suppported at design time, see go.microsoft.com/fwlink/?linkid=851728"
@marwan_sa5905
@marwan_sa5905 4 жыл бұрын
I'm facing the same issue, have you resolve it ?
@marwan_sa5905
@marwan_sa5905 4 жыл бұрын
o solve it the issue was i was missing ( , ) in appsetting.json after MyKey there was , missing { "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*", "MyKey": "Value of MyKey from appsettings.json", "ConnectionStrings": { "EmployeeDBConnection": "Server=(localdb)\\MSSQLLocalDB;database=EmployeeDB;Trusted_Connection=true" } }
@mdsaddamkhan8400
@mdsaddamkhan8400 4 жыл бұрын
I am getting this error in Package Manager console invalid value for key ' integrated security' Please someone help
@sanaafzal5316
@sanaafzal5316 5 жыл бұрын
thankyou sooooo much sir for these course......actually i have some problem in package manager console.......when i write Update_Database there is error occour. version problem how i solve this problem (The EF Core tools version '2.1.1-rtm-30846' is older than that of the runtime '2.1.11-servicing-32099'. Update the tools for the latest features and bug fixes.)
@tarn4t1on79
@tarn4t1on79 5 жыл бұрын
That's not an error, that's a warning. It'll still work just fine.
@lejinad5
@lejinad5 5 жыл бұрын
Hello! I am getting error when try to Add-Migration in PM: PM> add-migration cmdlet Add-Migration at command pipeline position 1 Supply values for the following parameters: Name: InitialMigration No migrations configuration type was found in the assembly 'WebApplication5'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration). When I type Enable-Migrations it said "No migrations configuration type was found in the assembly WebApplication5" But I do have AppDbContext.cs in dir. Models, and I have public class AppDbContext : DbContext (using Microsoft.EntityFrameworkCore) Can you please help me why I got this error? Thanks for great content!
@muhilansaravanan7106
@muhilansaravanan7106 4 жыл бұрын
EntityFrameworkCore\Add-Migration command
@salmanchowdarym1110
@salmanchowdarym1110 5 жыл бұрын
Thanks
@BalooCSGO69
@BalooCSGO69 4 жыл бұрын
You fucking king, You helped me so much, thank your my good friend.
@КсенияЮдина-ж6о
@КсенияЮдина-ж6о 5 жыл бұрын
I can't find the mdf file..
@SrikanthPuli4
@SrikanthPuli4 4 жыл бұрын
Could you make payment gateway in c# .net please.
@balkishan2k11
@balkishan2k11 4 жыл бұрын
How to implement automatic migrations without any dataloss
@MmMm-tg5mq
@MmMm-tg5mq 5 жыл бұрын
perfect
@kassandrasandoval8195
@kassandrasandoval8195 5 жыл бұрын
How does it know to name the database EmployeeDB?
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 5 жыл бұрын
Hello Kassandra - The database name is specified in the conncection string in appSettings.json file. Hope this answers your question.
@kassandrasandoval8195
@kassandrasandoval8195 5 жыл бұрын
@@Csharp-video-tutorialsBlogspot I see! I was confused because I would think the connection String value would come from the database name, not the other way around. Thank you for replying!
@muhammetsamkara1074
@muhammetsamkara1074 5 жыл бұрын
when program trying to read EmployeeDBConnection in start up I get an error of "System.ArgumentNullException: 'Value cannot be null. Parameter name: connectionString' " anybody who can help?
@renanrosa5527
@renanrosa5527 5 жыл бұрын
You are missing the letter 's' after the ConnectionString property name in the appsettings.json when using Configuration.GetConnectionString("name") Here is mine: "ConnectionStrings": { "EmployeeDBConnection": "server=(localdb)\\MSSQLLocalDB;database=EmployeeDB;Trusted_Connection=true" }
@nolimitsREAL
@nolimitsREAL 5 жыл бұрын
Seems a little bit complicated, just to create a database from the class that you created it.
@rimplechristian361
@rimplechristian361 3 жыл бұрын
how to add with DB first approch
@عمربنعبدالعزيزمحمدصالح-ر1ض
@عمربنعبدالعزيزمحمدصالح-ر1ض 5 жыл бұрын
I have Error:Value cannot be null. Parameter name: connectionString
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 5 жыл бұрын
This could have been caused by connection string not being initialised. Can you check if that's not the case. Hope this helps.
@CharkaouiOmar
@CharkaouiOmar 5 жыл бұрын
stackoverflow.com/questions/40874640/value-cannot-be-null-parameter-name-connectionstring-appsettings-json-in-start
@mughalnouman2406
@mughalnouman2406 4 жыл бұрын
@@Csharp-video-tutorialsBlogspot I have got the error the build failed
@karimkazia
@karimkazia 5 жыл бұрын
Excellent Video. though I came across an issue during the first process of migrations. i had to replace _config with configuration.UseSqlServer(XXXXXXX). otherwise it was not able to resolve the connection string name
@عمربنعبدالعزيزمحمدصالح-ر1ض
@عمربنعبدالعزيزمحمدصالح-ر1ض 5 жыл бұрын
I have Error:Value cannot be null. Parameter name: connectionString
@iamanalyst4u
@iamanalyst4u 5 жыл бұрын
Package manager consol not available on linux
@bulldog2024
@bulldog2024 5 жыл бұрын
You should be able to use the .net cli in the terminal to accomplish the same thing.
@sarozpradhan64
@sarozpradhan64 4 жыл бұрын
@@bulldog2024 how?? explain
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Can't run a server on a 32bit machine :(
@عمربنعبدالعزيزمحمدصالح-ر1ض
@عمربنعبدالعزيزمحمدصالح-ر1ض 5 жыл бұрын
I have Error:Value cannot be null. Parameter name: connectionString
@opraju
@opraju 5 жыл бұрын
I am unable to run InitialMigration - I am getting error InitialMigration : The term 'InitialMigration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + InitialMigration + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (InitialMigration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
@whopawan8384
@whopawan8384 5 жыл бұрын
IF PACKAGE MANAGER CONSOLE DID NOT FIND SESSION RUN THIS COMMAND ON PM. PM> Install-Package Microsoft.EntityFrameworkCore.Tools
@anvineet
@anvineet 5 жыл бұрын
I also get error after update name: PM> Add-Migration cmdlet Add-Migration at command pipeline position 1 Supply values for the following parameters: Name: InitialMigrainV An error occurred while accessing the IWebHost on class 'Program'. Continuing without the application service provider. Error: Could not parse the JSON file. Error on line number '7': '}, "AllowedHosts": "*",,'. Unable to create an object of type 'AppDbContext'. For the different patterns supported at design time, see go.microsoft.com/fwlink/?linkid=851728
@anvineet
@anvineet 5 жыл бұрын
Name: InitialMigration An error occurred while accessing the IWebHost on class 'Program'. Continuing without the application service provider. Error: Could not parse the JSON file. Error on line number '7': '}, "AllowedHosts": "*",,'. Unable to create an object of type 'AppDbContext'. For the different patterns supported at design time, see go.microsoft.com/fwlink/?linkid=851728
@anvineet
@anvineet 5 жыл бұрын
To avoid this situation, I create separate project and copy model/ startup project, then again try with "Add -Mirgration", We found this works.
@onurfurkan6757
@onurfurkan6757 5 жыл бұрын
ScriptHalted ?
@ksmith7611
@ksmith7611 4 жыл бұрын
Ha figured out why I couldn't use Add-Migration then I came here to tell everyone and found out that I should of looked here first ha ha (or well I am still a noob)
@prakashbuchade7642
@prakashbuchade7642 5 жыл бұрын
How can I use CosmosDb in back end with er core and migration?
@sabeenanarayanan8695
@sabeenanarayanan8695 5 жыл бұрын
After Giving the name for the migration it is showing the following error (Your target project 'Food' doesn't reference EntityFramework. This package is required for the Entity Framework Core Tools to work. Ensure your target project is correct, install the package, and try again.) Can you please tell me how to correct them
@UsmanAli-uzi
@UsmanAli-uzi 5 жыл бұрын
There could be 2 reasons: 1- You did not import the Entity framework core package. Refer to video#46 on how to install the package. 2- Or if you have already installed the package make sure when you open the nuget package manager console window, the correct project is selected. For example if you have 2 or more projects in your solution, one for web, one for data access and you only added the EFcore package to the data access project than make sure data access project is selected in the package manager console window. Another option is to select the data access project from the solution explorer before you open the nuget package manager console. That way it will know which project you want to run the migrations on.
@danieltutundziev5894
@danieltutundziev5894 3 жыл бұрын
XD
@oilha2011
@oilha2011 4 жыл бұрын
Perfect, many thanks!
@audiofrank6747
@audiofrank6747 3 жыл бұрын
Thank you so much!
@usamabaloch6178
@usamabaloch6178 4 жыл бұрын
I don't see any data in data base in sql server object explorer... where i am wrong can someone tells me?
Entity framework core seed data
7:20
kudvenkat
Рет қаралды 133 М.
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 329 М.
Introduction to entity framework core
4:45
kudvenkat
Рет қаралды 167 М.
139. What Are Your Thoughts on Entity Framework Core vs. Dapper?
21:49
Entity Framework Migrations Explained
36:53
dotnet
Рет қаралды 34 М.
Getting Started with Entity Framework Core in .NET
26:51
Nick Chapsas
Рет қаралды 37 М.
The Easiest Way To Manage Database Migrations in .NET
11:40
Nick Chapsas
Рет қаралды 42 М.
Repository pattern in asp net core
14:50
kudvenkat
Рет қаралды 311 М.
Part 1   What is Entity Framework
18:02
kudvenkat
Рет қаралды 980 М.