Wednesday 9 November 2011

“ The specified named connection is either not found in the configuration, not intended to be used with the EntityClient Provider, not valid. “

You will probably get this error when you are trying to use one edmx object from another project, and normally happens with a WCF service or a WinForm Application.

This is the scenario; we have one project where we have the data model (AxxiaDALSP) . In order to make that work we will call that dll (project) from our test harness (TestHarness) project. We are working with .NET 3.5 because we are developing something for Sharepoint and when we call our object we get: “The specified named connection is either not found in the configuration, not intended to be used with the EntityClient Provider, not valid.”.

image
How to sort it?, well it is easy:

  1. Be sure that the App.Config is empty:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    </configuration>

  2. Go to the edmx file and double click.
  3. Remove everything from there.
  4. Right click in the blank area->Update Model From Database. Follow the steps.
  5. Right click in the blank area->Properties->Metadata Artifact Processing:Embed in Output Assembly.
  6. Copy the generate connection string and paste it into your winform App.Config or Web.Config. This is what you should copy:
    <connectionStrings>
      <add name="axxia01Entities" connectionString="metadata=res://*/AxxiaDataModel.csdl|res://*/AxxiaDataModel.ssdl|res://*/AxxiaDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=xxxmyserverxxx;Initial Catalog=xxmytablexxx;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>

  7. Everything should work now!

Conclusion: This bug can be fixed in many ways, but this is the only one that worked for me. It comes in Visual Studio 2010.

3 comments:

Anonymous said...

Thanks! This solve!

I will copy this in my blog!

Thanks!Thanks!Thanks! =)

Anonymous said...

Thanks buddy!

Anonymous said...

it works.....thanks..