VS2017 中的 .NET Core 1.1:DbContextOptionsBuilder 不包含 'UseSqlServer' 的定义
.NET Core 1.1 in VS2017: DbContextOptionsBuilder does not contain a definition for 'UseSqlServer'
正在 VS2017 中处理一个新项目,但是当我为我的 dbContext 输入服务时,出现此错误:
Error CS1061 'DbContextOptionsBuilder' does not contain a definition for
'UseSqlServer' and no extension method 'UseSqlServer' accepting a first
argument of type 'DbContextOptionsBuilder' could be found (are you missing a
using directive or an assembly reference?)
Microsoft.EntityFrameworkCore.SqlServer v1.1.1 是否不再包含此功能,还是我遗漏了什么?
.csproj
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-
net45+win8+wp8+wpa81;</PackageTargetFallback>
<ApplicationIcon />
<OutputTypeEx>exe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore"
Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1"
/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design"
Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"
Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design"
Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug"
Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink"
Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design"
Version="1.1.0" />
<PackageReference Include="Novell.Directory.ldap.netstandard"
Version="2.3.6" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference
Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project>
如错误所说,
... (are you missing a using directive or an assembly reference?)
这是一种扩展方法,因此您确实需要 using Microsoft.EntityFrameworkCore;
我必须从 NuGet 安装 'Microsoft.EntityFrameworkCore.SqlServer'。
在程序包管理器控制台 I 运行:Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 1.1.2
我还必须确保我在 Startup.cs 文件中使用 using 语句引用了 Microsoft.EntityFrameworkCore:using Microsoft.EntityFrameworkCore;
。
正在 VS2017 中处理一个新项目,但是当我为我的 dbContext 输入服务时,出现此错误:
Error CS1061 'DbContextOptionsBuilder' does not contain a definition for
'UseSqlServer' and no extension method 'UseSqlServer' accepting a first
argument of type 'DbContextOptionsBuilder' could be found (are you missing a
using directive or an assembly reference?)
Microsoft.EntityFrameworkCore.SqlServer v1.1.1 是否不再包含此功能,还是我遗漏了什么?
.csproj
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-
net45+win8+wp8+wpa81;</PackageTargetFallback>
<ApplicationIcon />
<OutputTypeEx>exe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore"
Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1"
/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design"
Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer"
Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design"
Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools"
Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug"
Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink"
Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design"
Version="1.1.0" />
<PackageReference Include="Novell.Directory.ldap.netstandard"
Version="2.3.6" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference
Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project>
如错误所说,
... (are you missing a using directive or an assembly reference?)
这是一种扩展方法,因此您确实需要 using Microsoft.EntityFrameworkCore;
我必须从 NuGet 安装 'Microsoft.EntityFrameworkCore.SqlServer'。
在程序包管理器控制台 I 运行:Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 1.1.2
我还必须确保我在 Startup.cs 文件中使用 using 语句引用了 Microsoft.EntityFrameworkCore:using Microsoft.EntityFrameworkCore;
。