win7,64位,vs2015
net core生成数据库,使用Scaffold-DbContext报错“‘Scaffold-DbContext’ is not recognized as the name of a cmdlet”
学习的生成数据库信息的文章来自:http://www.cnblogs.com/baobaodong/p/5871357.html
运行的代码是:PM> Scaffold-DbContext "Data Source=.;Initial Catalog=test;User ID=sa;Password=sa1234" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Modles
就在网上搜索下,找到一篇:http://www.genshuixue.com/i-cxy/p/12865486
之后我吧代码加上,再次运行 Scaffold-DbContext
提示我powershell版本需要升级,我就从网上下载一个powershell3进行安装,重新启动电脑,但是还是不行,看到如下错误代码
下面看到的错误信息,有看到包名就进行安装下
System.AggregateException: One or more errors occurred. ---> Microsoft.EntityFrameworkCore.Design.OperationException: Unable to find design-time provider assembly. Please install the Microsoft.EntityFrameworkCore.SqlServer.Design NuGet package and ensure that the package is referenced by the project. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.EntityFrameworkCore.SqlServer.Design, Version=1.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. 系统锟揭诧拷锟斤拷指锟斤拷锟斤拷锟侥硷拷锟斤拷 at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolea n suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.GetProviderDesignTimeServices(String provider, Boolean throwOnError)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.GetProviderDesignTimeServices(String provider, Boolean throwOnError)
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(String provider)
at Microsoft.EntityFrameworkCore.Design.DatabaseOperations.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overw riteFiles, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Design.Internal.OperationExecutor.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnota tions, Boolean overwriteFiles, Cancell