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
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?
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...?
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.
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.
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?
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"
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!!
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"
1- Make sure all the projects in your solution are free from errors. 2- Make sure your connection string in the appsettings.json file in you WEB API project is pointing to your right database, whether your local or the the environment you intend to deploy this migration 3- Make sure your "startup project" points to WEB API while your project on the package manager console points to data access project or your web api if you have everything in your web api ONLY (NOT RECOMMENDED). 4- RUN UPDATE-DATABASE. 5- Cheers, grab a beer and relax!
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
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.
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?
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?
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.
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.
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..
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
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.
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.
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.)
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???
@@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
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"
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" } }
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!
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
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.
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?
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" }
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
@@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!
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)
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
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.
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
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
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
I am always amazed by the amount of time and energy you invest while preparing these materials.Still for free.Thank you so much.
I cant use Add-Migration before installed "Microsoft.EntityFrameworkCore.Tools"
in PM console: Install-Package Microsoft.EntityFrameworkCore.Tools
thank u so much bro .it helped me
I knew i was missing a package but thinking what it could be. Much appreciated.
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
Helped me too. Thanks a lot.
Thank u. you saved me at least 1 hour of my time :)
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!
You are making great .NET Engineers.
Be blessed.
simple, and straight to the point! Kudos!
Thank you, so much , but in .net core 3 and newer version we should install EntityFrameworkCore.Tools and then use Add-Migration
Thanks Man ! Saved me some time
Thanks!
Thank you again
for the excellent video
Best regards
I have Error:Value cannot be null.
Parameter name: connectionString
@@عمربنعبدالعزيزمحمدصالح-ر1ض make it connectionStrings
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?
Can you send me the code of this project on vaibhav.medavarapu@gmail.com. It really helps me in catching up. Thanks
the same here too i can't see the database created in the sqlserver. pls share how you get it work
You might have to refresh the database and it should be there.
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...?
it depends...
Thank you Sir for another great video As usual:)
The explanation is amazing 👏
My teacher thank you very much
Very useful lectures too
Thank you from the depths
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.
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.
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?
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"
I think this Migration is only for Code First approach right and not for Database First approach ?
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!!
I have an error...
The specified deps.json [D:\GitFirstCode\OnlineShop\Shop.UI\Shop.UI.deps.json] does not exist
Thanks again for the great content.
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"
stackoverflow.com/questions/40874640/value-cannot-be-null-parameter-name-connectionstring-appsettings-json-in-start
there is some solution
Thank you Venkat.
Thank you very much!
What about database first approach? I'm having really hard time figuring this out..
Çok teşekkür ediyorum. Çok iyi anlatıyorsunuz.
Thank you, your video save me
I keep getting an error when migrating "unable to create an object of type 'dbcontext'."
1- Make sure all the projects in your solution are free from errors.
2- Make sure your connection string in the appsettings.json file in you WEB API project is pointing to your right database, whether your local or the the environment you intend to deploy this migration
3- Make sure your "startup project" points to WEB API while your project on the package manager console points to data access project or your web api if you have everything in your web api ONLY (NOT RECOMMENDED).
4- RUN UPDATE-DATABASE.
5- Cheers, grab a beer and relax!
very informative nice video thanks a lot
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
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
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.
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?
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?
Very clear, thank you!
Plz I want buy à tutorial for unit test how I do that plz thank you
Venkat has a tutorial on Unit Testing in Udemy. Please find it
@@VinuP2023 does he have about other topics?
thanks alot My teacher need tutorial for unit test in asp.net core
Thanks for help)
So far so gud
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?
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.
thank you, Sir, it's clear now! :)
Thank you. Again
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.
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..
How can I create a table within an existing schema when I run update-Database. Please help
"Format of the initialization string does not conform to specification starting at index 0." I get an error
If you are getting error during add-migration Install Entity framework core package.
thanks for you
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
Did you solve it?
Awesome !
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.
Hi! The souce code can be found on the blogspot. You can check them out at the description section under every videos. :)
Please make a video on Response caching in .net core if possible
package manager console does not recognize the add-migration command. how do fix this?
in the package manager console run this command Install-Package Microsoft.EntityFrameworkCore.Tools
While doing migration it gives an error deps. Json(path) does not exist.
I am getting this error in Package Manager console
invalid value for key ' integrated security'
Please someone help
hello venkat sir please help me ,i m unable to update-database cammand in console package manager
Same
MOdify connection string as "EmployeeDBConnection": "Server=.;Database=EmployeeDB;Trusted_Connection=true"
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.
But 99% of projects does have existing Database. does it means this code first wont work?
I can't find the mdf file..
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.)
That's not an error, that's a warning. It'll still work just fine.
PlatformNotSupportedException: LocalDB is not supported on this platform. ??ubuntu
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???
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.
I want to create mysql db migrations code first? Can u guide?
Just Install this package mysql.entityframeworkcore5.0.0 instead of SQL.EntityFramework and do the same (connection string to your mysql db)
@@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
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"
I'm facing the same issue, have you resolve it ?
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"
}
}
i am getting this exception please help me
ArgumentException: Invalid value for key 'integrated security'.
try Trusted_Connection=True instead of integrated security at EmployeeDBConnection in Appsetting.json file
@@PriyankaSoni2014 yup... I used the same I am getting different level of error right now
@@mdsaddamkhan8400 use -> integrated security= SSPI
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!
EntityFrameworkCore\Add-Migration command
Thanks sir :)
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
Could you make payment gateway in c# .net please.
You fucking king, You helped me so much, thank your my good friend.
How did it knew that the primary key should be ID? (table.PrimaryKey("PK_Employees", x => x.Id);)
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.
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?
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"
}
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'
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
I have Error:Value cannot be null.
Parameter name: connectionString
How to implement automatic migrations without any dataloss
i have error
Exception has been thrown by the target of an invocation.
Great job as always keep it up ill build you a Monument if i become rich :D
I think he didn't need your Monument , if you can help just donate at his blog
И јас го делам истото мислење за чоеков !
How does it know to name the database EmployeeDB?
Hello Kassandra - The database name is specified in the conncection string in appSettings.json file. Hope this answers your question.
@@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!
Thank You
how to add with DB first approch
Seems a little bit complicated, just to create a database from the class that you created it.
Thanks
perfect
How can I use CosmosDb in back end with er core and migration?
Can't run a server on a 32bit machine :(
I have Error:Value cannot be null.
Parameter name: connectionString
ScriptHalted ?
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)
Package manager consol not available on linux
You should be able to use the .net cli in the terminal to accomplish the same thing.
@@bulldog2024 how?? explain
I have Error:Value cannot be null.
Parameter name: connectionString
This could have been caused by connection string not being initialised. Can you check if that's not the case. Hope this helps.
stackoverflow.com/questions/40874640/value-cannot-be-null-parameter-name-connectionstring-appsettings-json-in-start
@@Csharp-video-tutorialsBlogspot I have got the error the build failed
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
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.
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
IF PACKAGE MANAGER CONSOLE DID NOT FIND SESSION RUN THIS COMMAND ON PM.
PM> Install-Package Microsoft.EntityFrameworkCore.Tools
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
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
To avoid this situation, I create separate project and copy model/ startup project, then again try with "Add -Mirgration", We found this works.
XD
Perfect, many thanks!
Thank you so much!
I don't see any data in data base in sql server object explorer... where i am wrong can someone tells me?