使用程序包管理控制台生成sqlite数据库迁移文件和数据迁移时报错误信息

发布于 2020-04-14 22:27:36

如题
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
System.NullReferenceException: Object reference not set to an instance of an object.
at WalkingTec.Mvvm.Mvc.FrameworkServiceExtension.<>c.<GetAllModels>b__6_0(CS x)
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at WalkingTec.Mvvm.Mvc.FrameworkServiceExtension.GetAllModels(Configs con)
at WalkingTec.Mvvm.Mvc.FrameworkServiceExtension.AddFrameworkService(IServiceCollection services, Func2 CsSector, List1 dataPrivilegeSettings, WebHostBuilderContext webHostBuilderContext)
at tcl.smarthome.platform.Program.<>c.<CreateWebHostBuilder>b__10_2(WebHostBuilderContext hostingCtx, IServiceCollection x) in D:codeManagergitee.comprivatetcl.smarthome.platformtcl.smarthome.platformProgram.cs:line 69
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass10_0.<ConfigureServices>b__0(HostBuilderContext context, IServiceCollection builder)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Object reference not set to an instance of an object.
No application service provider was found.
Finding DbContext classes in the project...
Found DbContext 'DataContext'.
Using DbContext factory 'DataContextFactory'.

但能生成迁移文件,也能生成数据库和表。不知道报错是什么问题。

查看更多

关注者
0
被浏览
663
刘亮
刘亮 2020-04-14
专业编码30年

检查一下 DataContext.cs文件中的 DataContextFactory类,里面连接字符串是否填写正确

1 个回答

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览