开发环境:
WIN7 64 旗舰
VS2017
PowerShell 3.0
使用EF的Database First模式(已经存在数据库,在VS中使用EF将表映射为Models)
按照微软官方的教程之前的几个命令:
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design
都顺利执行完毕,在执行:
Scaffold-DbContext "Server=(local);Database=PADAccountLD;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -Verbose
时出错,完整的错误提示是:
Using project 'PADBS.Models'.
Using startup project 'PADBrushSystem'.
Build started...
Build succeeded.
E:\CSharp\Projects\PADBrushSystem\packages\Microsoft.EntityFrameworkCore.Tools.1.1.1\tools\net451\ef.exe dbcontext scaffold Server=(local);Database=PADAccountLD;Trusted_Connection=True; Microsoft.EntityFrameworkCore.SqlServer --json --verbose --no-color --prefix-output --assembly E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\bin\Debug\PADBS.Models.dll --startup-assembly E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\bin\Debug\PADBrushSystem.exe --project-dir E:\CSharp\Projects\PADBrushSystem\PADBS.Models\PADBS.Models\ --content-root E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\ --data-dir E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\bin\Debug\ --root-namespace PADBS.Models
Using assembly 'PADBS.Models'.
Using startup assembly 'PADBrushSystem'.
Using application base 'E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\bin\Debug'.
Using content root 'E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\'.
Using root namespace 'PADBS.Models'.
Using project directory 'E:\CSharp\Projects\PADBrushSystem\PADBS.Models\PADBS.Models\'.
Using data directory 'E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\bin\Debug\'.
Using configuration file 'E:\CSharp\Projects\PADBrushSystem\PADBrushSystem\bin\Debug\PADBrushSystem.exe.config'.
System.IO.FileNotFoundException: δ�ܼ����ļ������Microsoft.EntityFrameworkCore.Design��������ijһ�������ϵͳ�Ҳ���ָ�����ļ���
�ļ���:��Microsoft.EntityFrameworkCore.Design��
�� System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
�� System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
�� System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
�� System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
�� System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
�� System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
�� System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
�� Microsoft.EntityFrameworkCore.Tools.AppDomainOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String contentRootPath, String dataDirectory, String rootNamespace, String environment)
�� Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()
�� Microsoft.EntityFrameworkCore.Tools.Commands.DbContextScaffoldCommand.Execute()
�� Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
�� Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
����: ������־��¼���رա�
Ҫ���ó���ʧ����־��¼���뽫ע���ֵ [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD)����Ϊ 1��
ע��: ����һЩ�����ʧ����־��¼������������ʧ��
Ҫ�رմ˹��ܣ����Ƴ�ע���ֵ [HKLM\Software\Microsoft\Fusion!EnableLog]��
δ�ܼ����ļ������Microsoft.EntityFrameworkCore.Design��������ijһ�������ϵͳ�Ҳ���ָ�����ļ���
你没看错,中间出现好多乱码。这什么情况 ?
问题出在哪里 ?
安装Microsoft.EntityFrameworkCore.Design即可。