Package manager Console add-migration addCategoryToDatabase

Joined
Aug 14, 2021
Messages
18
Programming Experience
Beginner
Hello,

For some reason while I'm trying to write the function add-migration addCategoryToDatabase,it shows that the PM failed.

timeframe: 1:06:54. Maybe the
Screenshot 2021-08-23 192257.png
names are different,butI also Installed the neccessary microsoft entity tools package.I'm completely lost.Thank you for your information.
 

Attachments

  • Screenshot 2021-08-23 192605.png
    Screenshot 2021-08-23 192605.png
    41.7 KB · Views: 42
  • Screenshot 2021-08-23 192803.png
    Screenshot 2021-08-23 192803.png
    179.2 KB · Views: 44
I don't use EF because of I just find it to buggy, so take the following with a huge grain of salt. From my understanding of EF's convention for migrations is that the name convention for a migration is "Add Class Field", but from your screen shots, it looks like you trying to do "add Field To Class".
 
In order to call that UseSqlServer extension method, you need to have added the Microsoft.EntitiyFrameworkCore.SqlServer NuGet package and you also need to import the Microsoft.EntityFrameworkCore namespace in the file that it's used in. All extension methods require the namespace that their type is a member of to be imported. In this case, you're calling the Microsoft.EntityFrameworkCore.SqlServerDbDontextOptionsExtension.UseSqlServer method.
 
In order to call that UseSqlServer extension method, you need to have added the Microsoft.EntitiyFrameworkCore.SqlServer NuGet package and you also need to import the Microsoft.EntityFrameworkCore namespace in the file that it's used in. All extension methods require the namespace that their type is a member of to be imported. In this case, you're calling the Microsoft.EntityFrameworkCore.SqlServerDbDontextOptionsExtension.UseSqlServer method.
Thank you very much.I have installed Microsoft.EntitiyFrameworkCore.SqlServer NuGet package,but I don't understand how should I import the Microsoft.EntityFrameworkCore namespace in the file that it's used in? Because my file name is Net5realproject.
 
I don't use EF because of I just find it to buggy, so take the following with a huge grain of salt. From my understanding of EF's convention for migrations is that the name convention for a migration is "Add Class Field", but from your screen shots, it looks like you trying to do "add Field To Class".
Thanks for your reply.I don't even know what an EF is. And how could I change the name convention for a migration because I don't see where the "Add Class Field" is?
 
EF is Entity Framework. That's what you are currently using in that tutorial that you are following. You probably want to type in add-migration AddDatabaseCategory instead of what you are currently doing: add-migration addCategoryToDatabase.
 
Firstly, please don't post code and error messages as just pictures. If a screenshot adds value then you can include it as well but you need to ALWAYS post code and error messages as text, formatted appropriate. We cannot copy and paste from a picture if we want to search the web for keywords or run code. It's a waste of our time to have to retype stuff that you already have and should have provided. There are also issues with readability of pictures on mobile devices. Several of the key contributors here often view threads on their phones, myself included, and pictures are much harder to deal with that text.
 
As for the errors, you need to do a better job of reading what's in front of you. The first one is obviously a misspelling: it's "Application", not "Apllication". The second one has already been addressed earlier in this thread.
 
Back
Top Bottom