Print Page | Close Window

Cannot connect to database or BOS - configuration problem

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2678
Printed Date: 13-Oct-2025 at 3:47am


Topic: Cannot connect to database or BOS - configuration problem
Posted By: Randar
Subject: Cannot connect to database or BOS - configuration problem
Date Posted: 13-May-2011 at 2:17pm
I have taken an existing WinForm application and trying to integrate with DevForce 2010.  The problem is, every time i try to actually get an entity, I get the following:

Key 'EntityManager_GL': The connection string for Key 'EntityManager_GL' was not found or is invalid.  Check that either a connectionStrings element or EdmKey is defined for this key in the configuration file, or implement a custom IDataSourceKeyResolver.

The EntityManager instantiates fine, or seems as soon as I call .ToList or .FirstOrDefault, I get that error.  What I did was:

1) Created a new project that has my EDMX
2) Added a new BOS as a website on port 9009.  This has a reference to my EDM project.  Seems to load fine when I hit the EntityService.svc via a browser.
3) Added reference in my WinForm to IdeaBlade Core, EntityModel Linq and Validation and my EDM project.
4) Added the following to the App.Config for the WinForm.

  <configSections>
    <section name="ideablade.configuration" type="IdeaBlade.Core.Configuration.IdeaBladeSection, IdeaBlade.Core"/>
  </configSections>

  <connectionStrings>
    <add name="JonasNET_Entities" connectionString="metadata=res://*/GL.csdl|res://*/GL.ssdl|res://*/GL.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost\sqlExpress;Initial Catalog=XXXXX;Persist Security Info=True;User ID=XXXXXX;Password=XXXXXX;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
 
  <ideablade.configuration version="6.00" xmlns="http://schemas.ideablade.com/2010/IdeaBladeConfig">

    <logging logFile="DebugLog.xml"/>

    <objectServer remoteBaseURL="http://localhost" serverPort="9009" serviceName="EntityService.svc" >
      <clientSettings isDistributed="true" />
    </objectServer>

    <!-- Additional configuration can be added to override defaults.
         See the sample config files in the Learning Resources for more information.
    -->

  </ideablade.configuration>


I've tried with both isDistributed and false and get the exact same error.  I cannot figure out why it can't find the WS or my connection string.

Thoughts?  What step did I miss?



Replies:
Posted By: DenisK
Date Posted: 13-May-2011 at 3:00pm
Hi Randar;

The name of your EntityManager must match with the name in your connections string. In this case, your EntityManager name is EntityManager_GL but in your connection string, you have JonasNET_Entities.

Please let me know if this fixes the problem. You can also see this page for more discussion on how DevForce handles data source keys as well as creating a dynamic connection string.

http://drc.ideablade.com/xwiki/bin/view/Documentation/data-sources - http://drc.ideablade.com/xwiki/bin/view/Documentation/data-sources

Hope this helps.


Posted By: Randar
Date Posted: 16-May-2011 at 7:14am
Bingo, that fixed it.  Thanks for the answer and link.


Posted By: DenisK
Date Posted: 16-May-2011 at 11:22am
Sounds good. I'd like to correct one of my statements as well.

"The name of your EntityManager must match with the name in your connections string".

That is incorrect. In the generated code, there's a DataSourceKeyName attribute that is applied to the sub-typed EntityManager. And that key name is what DevForce searches in the config file for the connection string.

Sorry for the confusion.



Print Page | Close Window