为了跟进新本版,在安装了vs2017之后,我就迫不及待地搭建了一个项目进行测试。


(这个官网给的安装EF框架以及生产实体类操作步骤,操作是在VS2015下操作的不过也没什么差别)

如何在 ASP.NET Core 中使用 Entity Framework DB First


错误:

    

6362655257211795973339818.png

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null'. 系统找不到指定的文件。

File name: 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null'

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)

   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder)

   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)

   at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String contentRootPath, String dataDirectory, String rootNamespace, String environment)

   at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()

   at Microsoft.EntityFrameworkCore.Tools.Commands.DbContextScaffoldCommand.Execute()

   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)

   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)

Could not load file or assembly 'Microsoft.EntityFrameworkCore.Design, Culture=neutral, PublicKeyToken=null'. 系统找不到指定的文件。


解决方案:把项目设置成启动项目就可以解决这个错误了,没错就是把项目设置成启动项目就可以了。