我刚刚安装了VS2017 Enterprise,试图创建空白的UWP项目。 然后我添加了一个派生自DbContext
的类using Microsoft.EntityFrameworkCore;
namespace Test
{
public class TestContext : DbContext
{
}
}
编译器不喜欢上面的简单类并且抱怨:
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
虽然我确实安装了sqlite包
Install-Package Microsoft.EntityFrameworkCore.Sqlite
安装成功。
我错过了什么?也许我需要添加一个DLL的引用,但我应该使用哪个DLL?
更新 我尝试按照建议安装Microsoft.EntityFrameworkCore(主程序包),但它似乎不兼容。
supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package Microsoft.EntityFrameworkCore 2.0.1 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-arm. Package
Microsoft.EntityFrameworkCore 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package Microsoft.EntityFrameworkCore 2.0.1 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-arm-aot. Package
Microsoft.EntityFrameworkCore 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package Microsoft.EntityFrameworkCore 2.0.1 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x64. Package
Microsoft.EntityFrameworkCore 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package Microsoft.EntityFrameworkCore 2.0.1 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x64-aot. Package
Microsoft.EntityFrameworkCore 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package Microsoft.EntityFrameworkCore 2.0.1 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x86. Package
Microsoft.EntityFrameworkCore 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package Microsoft.EntityFrameworkCore 2.0.1 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x86-aot. Package
Microsoft.EntityFrameworkCore 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package restore failed. Rolling back package changes for 'TestEntityFW'.
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
答案 0 :(得分:0)
您还必须安装EF Core的主程序包
Install-Package Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Sqlite只是Entity Framework Core的数据库提供程序包,例如Microsoft.EntityFrameworkCore.SqlServer。