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

Posts   
 
    
Jakes
User
Posts: 8
Joined: 21-Jun-2010
# Posted on: 21-Jun-2010 13:48:49   

Hi

After I generated the code, I created a Test Application to test the EF4 Data Context. I tried to initiate the model with the following...


var dataContext = new AdventureWorksEf4DataContext();

... and I get the following exception


System.ArgumentException was unhandled
  Message=The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
  Source=System.Data.Entity
  StackTrace:
       at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
       at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
       at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
       at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
       at AW.AdventureWorksEf4DataContext..ctor() in C:\Temp\GeneratorTest\v3\AW\Persistence\AdventureWorksEf4DataContext.cs:line 97
       at AW.TestEntity.Program.Main(String[] args) in C:\Temp\GeneratorTest\v3\AW\AW\AW.TestEntity\Program.cs:line 10
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

This is in the App.Config ...



<connectionStrings>
        <!-- please adjust the connection string embedded in the element below to target the proper catalog / server using the proper user / password combination -->
        <add name="ConnectionString.SQL Server (SqlClient)" connectionString="metadata=res://*/AdventureWorksEf4.csdl|res://*/AdventureWorksEf4.ssdl|res://*/AdventureWorksEf4.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=master;User ID=***;Password=***;persist security info=False;packet size=4096&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>

I used the video on the LLBLGen website as a screen cast to get to grips with the product. If anyone can help with this, please.

Thank you

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Jun-2010 14:29:52   

Did you copy the generated config file into your application?

Jakes
User
Posts: 8
Joined: 21-Jun-2010
# Posted on: 21-Jun-2010 14:54:25   

Walaa wrote:

Did you copy the generated config file into your application?

It was the config file.

All sorted out.

Thanks