【发布时间】:2017-08-18 08:23:44
【问题描述】:
我们在项目中同时使用 EF6 和 EF Core。我有其他团队成员创建的迁移。我想使用下一个命令更新数据库:
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 Core 模块,但它在项目包文件夹中,我检查了它。
Import-Module 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
我现在不使用t understand why i cant,为什么 NPM 不能精细 EF Core 模块。
在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 框架 4.6.2
【问题讨论】:
-
我可能误读了这一点,但我认为您不能在 .Net Framework 上下文中使用实体框架核心。您的应用程序需要使用 netcoreapp2.0 的目标框架。
-
@Jack 我的团队成员也有相同的项目配置,并且可以正常工作。看看我们现在使用的 EF Core 版本。
标签: c# entity-framework orm asp.net-core entity-framework-core