我的开发环境中安装了VS2017,ASP.NET CORE,VS Code和SQL Server 2014。
我从链接https://github.com/mmacneil/ASPNetCoreGraphQL下载了示例代码,然后使用VSCode将其打开。
我创建了一个名称为NHLStats
的数据库,并将连接字符串更新为
"NHLStatsDb": "Data Source=.;Initial Catalog=NHLStats;Trusted_Connection=True;MultipleActiveResultSets=true"
根据README.md文档中提到的说明,我导航到\ NHLStats.Api文件夹的根目录,然后执行CLI dotnet run命令。
在运行上述命令时,我看到以下错误:
应用程序启动异常:System.ArgumentNullException:值不能为null。
参数名称:connectionString在Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(字符串值,字符串parameterName)
在Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder,String connectionString,Action1 sqlServerOptionsAction) at NHLStats.Api.Startup.<>c__DisplayClass4_0.<ConfigureServices>b__0(DbContextOptionsBuilder options) in C:\Temp\ASPNetCoreGraphQL-master\src\backend\NHLStats.Api\Startup.cs:line 31 at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action
2 optionsAction)中 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider提供者,类型serviceType) 在Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService [T](IServiceProvider提供程序) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite构造函数CallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite构造函数CallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transitionCallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite构造函数CallSite,ServiceProviderEngineScope范围) 在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围) 在NHLStats.Api.Startup中。<> c__DisplayClass4_0.b__1(Type type)在C:\ Users \ sapatro \ Learning \ GraphQLDetails \ ASPNetCoreGraphQL-master \ src \ backend \ NHLStats.Api \ Startup.cs:line 41中 在GraphQL.FuncDependencyResolver.ResolveT 在C:\ Temp \ ASPNetCoreGraphQL-master \ src \ backend \ NHLStats.Api \ Models \ NHLStatsSchema.cs:line 11中的NHLStats.Api.Models.NHLStatsSchema..ctor(IDependencyResolver解析器)处 在NHLStats.Api.Startup.ConfigureServices(IServiceCollection服务)中的C:\ Temp \ ASPNetCoreGraphQL-master \ src \ backend \ NHLStats.Api \ Startup.cs:第41行 ---从之前引发异常的位置开始的堆栈结束跟踪--- 在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection服务) 在Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices() 在Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()