Just install Microsoft.EntityFrameworkCore.Tools
package from nuget:
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0.7
You can also use this link to install the latest version: NuGet package link
.NET CLI command:
dotnet add package Microsoft.EntityFrameworkCore.Tools
If the problem still persists, try restarting Visual Studio.
Try the following steps:
1) Open project.json
file and Remove all Microsoft.EntityFrameworkCore.Tools references from dependencies and tools sections.
2) Close Package Manager Console (PMC) and restart Visual Studio
3) Add under dependencies section:
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
}
4) Add under tools section
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
5) Restart again Visual Studio 2015
6) Open the PMC and type
Add-Migration $Your_First_Migration_Name$
This happen because the PMC recognize the tools when Visual Studio is starting.
Ensure Microsoft.EntityFrameworkCore.Tools
is referenced in the dependencies
section of your project.json
. NuGet won't load the Package Manager Commands from the tools
section. (See NuGet/Home#3023)
{
"dependencies": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
}
}
}
same issue...resolved by dong the following
1.) close pm manager 2.) close Visual Studio 3.) Open Visual Studio 4.) Open pm manager
seems the trick is to close PM Manager before closing VS
From Asp.Net Core 5.0 perspective
In the Migrations project Install the following:
In the Startup/Api project Install the following:
Ensure that you have added DbContext derived type to the services collection by using following line of code in Startup.ConfigureServices(IServiceCollection services):
services.AddDbContext<YourDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("YourDb"),
x=>x.MigrationsAssembly("Your.Migrations")));
I just had this problem too. I closed and opened VS2015 and it "fixed" the issue...
You have to know what is your Entity-Framework
version.
Also after that you have to check project.json
and control these sections:
In Dependencies
check:
Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
This section:
"version": "1.0.0-preview2-final",
is related with version of your Entity-Framework
and you have to change this with that.
After that the second section of the proj.json
is here, In the Tools
section of JSON
you have:
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
Also this part of code is related with your Entity-Framework
and last part of code in Dependencies section.
Note: After do this issues you should to close CMD
and restart visual studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With