从ASP.NET Angular项目中获取AppConfig错误

时间:2018-10-30 14:24:06

标签: c# asp.net asp.net-core entity-framework-6

我创建了一个数据存储库,并使用Angular Project创建了API。现在,当我调用API时,出现以下错误:

“ System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发了异常。

Stacktrace如下

at System.Data.Entity.Internal.LazyInternalConnection..ctor(DbContext context, String nameOrConnectionString)
at System.Data.Entity.DbContext..ctor(String nameOrConnectionString)

at DataProvider.hclunisondevEntities..ctor() in C:\Development\Unison\hclunison\DataProvider\DataModel.Context.cs:line 21

at DataProvider.UnisonDataProvider.get_GetUnisonDataEntity() in C:\Development\Unison\hclunison\DataProvider\UnisonDataProvider.cs:line 26

at DataProvider.UnisonDataProvider.GetAllCountries() in C:\Development\Unison\hclunison\DataProvider\UnisonDataProvider.cs:line 36

at BusinessLayer.GenericData.GetAllCountries() in C:\Development\Unison\hclunison\BusinessLayer\GenericData.cs:line 40

at Unison.Controllers.SampleDataController.GetCountries() in C:\Development\Unison\hclunison\Unison\Controllers\SampleDataController.cs:line 51

at lambda_method(Closure , Object , Object[] )

at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)

at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()

我的连接方式如下

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <connectionStrings>
        <add name="hclunisondevEntities" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=hclunison.database.windows.net;initial catalog=mydb;user id=somethig;password=pass@12345;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
        <providers>
            <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
    </entityFramework>
</configuration>

我无法理解为什么在运行我的角度应用程序时会出现此错误。

0 个答案:

没有答案