I wanted to call an ExceptionHandler in a helper class. The ExceptionHandler uses Entity Framework to store the error. Then I tried to call the ExceptionHandler from a Logic App. The Logic App selects data, but does so via ADO.Net and not via the Entity Framework. The first error I received is that the EF connection string cannot be found.
Remember: you will have to add the EF connection string to the config file of the calling app. The config file is what counts when it comes to the connection string, not the config file of the ErrorHandler itself. Below is an example of the connection string I added (note that there are both the EF connection string and the ADO.Net connection string):
<add name=”EntityModelCommon_v10″ connectionString=”metadata=res://*/CommonEntities.csdl|res://*/CommonEntities.ssdl|res://*
/CommonEntities.msl;provider=System.Data.SqlClient;provider connection string=”data source=bvgo-dev-sqlazure.database.windows.net;initial catalog=bvgo-appservices;user id=—;password=—;MultipleActiveResultSets=True;App=EntityFramework”” providerName=”System.Data.EntityClient” />
<add name=”bvgo-appservices” connectionString=”Server=tcp:bvgo-dev-sqlazure.database.windows.net,1433;Database=bvgo-appservices;User ID=—;Password=—;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;” />
Then I received the following error:
No Entity Framework provider found for the ADO.NET provider with invariant name ‘System.Data.SqlClient’. Make sure the provider is registered in the ‘entityFramework’ section of the web.config file.
The solution to this problem was very simple. I had to add the Entity Framework NuGet package to the references of the Logic App. This may sound counter
intuitive because the Logic App itself doesn’t use EF, but believe me: it works! Below is the section that is added to the web.config file of the Logic App:
<defaultConnectionFactory type=”System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework”>
<parameter value=”mssqllocaldb” />
<provider invariantName=”System.Data.SqlClient” type=”System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer” />
Note the provider System.Data.SqlClient, the provider that was missing.