I am new to EF core and I\'m trying to get it to work with my ASP.NET Core project.
I get the above error in my startup.cs
when trying configure the
Install below NuGet Package will solve your issue
Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.SqlServer
In Visual Studio, check the NuGet Package Manager => Manage Packages for Solution, check all this packages, whether got installed in your solution or not, as below:
I solved the same issues after check all the above packages have been installed.
Follow the steps below.
Install Entity Framework Core Design and SQL Server database provider for Entity Framework Core:
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
Import Entity Framework Core:
using Microsoft.EntityFrameworkCore;
And configure your DbContext:
var connectionString = Configuration.GetConnectionString("myDb");
services.AddDbContext<MyDbContext>(options =>
options.UseSqlServer(connectionString)
);
first add Install-Package Microsoft.EntityFrameworkCore.SqlServer
next add in your .cs file using Microsoft.EntityFrameworkCore;
finally add this in your core Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFrameworkSqlServer().AddDbContext<ApplicationContext>(options => options.UseSqlServer(Configuration.GetConnectionString("MovieContext")));
}
Install-Package:
**Microsoft.EntityFrameworkCore.SqlServer**
then add the top of your class:
**Microsoft.EntityFrameworkCore;**
that's worked for me
This is a known issue in the project system. See dotnet/project-system#1741