我們在項目中同時使用了EF6和EF Core。我有其他團隊成員創建的遷移。我想用一個命令來更新數據庫:實體框架核心命令在Nuget PM中無法識別
EntityFrameworkCore \更新,數據庫
但接下來的錯誤發生:
EntityFrameworkCore\Update-Database : The module 'EntityFrameworkCore' could not be loaded. For more information, run 'Import-Module EntityFrameworkCore'.
At line:1 char:1
+ EntityFrameworkCore\Update-Database
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (EntityFrameworkCore\Update-Database:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
它寫的是,EF核心模塊無法加載,但它在項目包文件夾中,我檢查它。
導入模塊EntityFrameworkCore命令執行結果:
Import-Module : The specified module 'EntityFrameworkCore' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
+ Import-Module EntityFrameworkCore
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (EntityFrameworkCore:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
我現在使用它穿上噸,爲什麼NPM不能精細EF核心模塊。
此包中的csproj文件中提到:
<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.1.1" />
<PackageReference Include="EntityFramework" Version="6.1.3" />
<PackageReference Include="IdentityServer4" Version="1.5.2" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="1.2.1" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="1.0.1" />
<PackageReference Include="IdentityServer4.EntityFramework" Version="1.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="System.Linq.Dynamic" Version="1.0.7" />
</ItemGroup>
有人可以告訴我,我在做什麼錯?沒有EntityFrameworkCore前綴的更新數據庫被識別。 .Net Framework 4.6.2
我可能會誤解這個,但我不認爲你可以在.Net Framework上下文中使用實體框架核心。你的應用程序需要使用netcoreapp2.0的目標框架。 – Jack
@Jack我的團隊成員也具有相同的項目配置,並且工作正常。看看我們現在使用的EF Core版本。 –