0

I have an app that is called on a remote web hosting server. It calls up customer details and amends records in response to notification of a sale. It used to work fine but recently it does not.

The exception is:

System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at GSnet.Models.GreenhillSoftwareEntities..ctor() in C:\Users\Mike\source\repos\GSnetA\Models\GsEntityModel1.Designer.cs:line 50
at GSnet.GSData.ProcessPurchase(Transaction payPalTransaction) in C:\Users\Mike\source\repos\GSnetA\GSData.cs:line 58

I have double checked the connection string and cannot see anything wrong with it. Here it is below with XXXs replacing sensitive data.

<add name="xxxxSoftwareEntities" 
     connectionString="metadata=res://*/Models.GsEntityModel.csdl|res://*/Models.GsEntityModel.ssdl|res://*/Models.GsEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=xxxxx.net;initial catalog=xxxxx_db;user id=greenhi1;password=xxxxx;multipleactiveresultsets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

If I run it on my dev machine to debug it calls the remote database quite happily but when the same code and the same connection string are on the remote hosting server then it falls over the first time it calls for any data.

I have racked my brain to remember any significant changes, consulting my GIT history etc. but I am stumped.

Can anyone give me any pointers?

I have tried recopying both the code and the connections string/web.config to the server and added some logging so I know which version of the code is running. It still failed.

6
  • Did you have one project with the entityFramework and another one with the webApp in your solution? Commented Oct 28, 2024 at 19:24
  • You're still using System.Data.SqlClient instead of Microsoft.Data.SqlClient? What versions of System.Data.SqlClient do you have installed locally and remotely? Commented Oct 29, 2024 at 0:27
  • Any useful clues in this previous question, The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid? Commented Oct 29, 2024 at 1:17
  • You can try to build the connectionstring with some help from microsoft. Create a text file anywhere and rename it so it has extension .udl Now doubleclick on that file from windows explorer, now you have a tool that can assist a little in building a working connection string. When you get it working in this tool, then open the udl text file with notepath and you will get the connectionstring as text again Commented Oct 29, 2024 at 6:37
  • Thanks for the feeback. In answer to questions It is all one solution on my dev machine. I copied the .dll, .pdb, EntityFramework.SqlServer.dll & EntityFramework.dll to the bin folder of the hosting server. The EntityFramework is 6.400.420.21404 on both local and remote. I am not using System.Data.SqlClient but System.Data.EntityClient Commented Oct 31, 2024 at 15:26

1 Answer 1

0

use trustservercertificate=True;

Hope after that, it will work

Sign up to request clarification or add additional context in comments.

1 Comment

Can you provide some explanation of how this solves the problem in the question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.