Entity Framework Core: DbContextOptionsBuilder does not contain a definition for 'usesqlserver' and no extension method 'usesqlserver'

前端 未结 30 3163
星月不相逢
星月不相逢 2020-12-13 03:14

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

30条回答
  •  自闭症患者
    2020-12-13 03:41

    I was using Visual Studio Code.

    1) Try to install the package 'Microsoft.EntityFrameworkCore.SqlServer' by specifying the version number.

    VS Code:

    'dotnet add package Microsoft.EntityFrameworkCore.SqlServer -v 1.1.1'

    Visual Studio:-

    'Install-Package Microsoft.EntityFrameworkCore.SqlServer -v 1.1.1'

    Refer the link 'Package 'Microsoft.EntityFrameworkCore.SqlServer' is incompatible with 'all' frameworks in the project' for doing it.

    2) Then add the namespace 'using Microsoft.EntityFrameworkCore;' manually in the Startup.cs file.

    Refer the below link https://github.com/aspnet/EntityFramework/issues/7891.

    3) If you get any dependency issue for 'Microsoft.EntityFrameworkCore.SqlServer.Design', like "Package 'Microsoft.EntityFrameworkCore.Design' is incompatible with 'all' frameworks in project" ,we need to run the below command,

    VS Code:-

    dotnet add package Microsoft.EntityFrameworkCore.Design -v 1.1

    Visual Studio

    Install-Package Microsoft.EntityFrameworkCore.Design -v 1.1

提交回复
热议问题