Print Page | Close Window

IDataSourceKeyResolver example

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=4573
Printed Date: 07-Jun-2024 at 5:38pm


Topic: IDataSourceKeyResolver example
Posted By: vecs
Subject: IDataSourceKeyResolver example
Date Posted: 24-Oct-2013 at 4:43am
I am thinking of use IDataSourceKeyResolver for dynamic Connection strings handling.
I got test solution from here:
http://drc.ideablade.com/xwiki/bin/view/Documentation/code-sample-custom-datasourcekeyresolver
but it does not work.

I have the following situation:

* ServerModelTomato.Tomato entity have attribute:
[IbEm.DataSourceKeyName(@"Tomato")]

* Console01. Program execute this:

      var entityManager = new DomainModelEntityManager(true, "Customer01");
      foreach (var tomato in entityManager.Tomatoes) {
        Console.WriteLine("Tomato {0}", tomato.Variety);
      }


* During first call to entityManager.Tomatoes, CustomDataSourceKeyResolver.GetKey method invoked
and proper 'Tomato_Customer01' ClientEdmKey generated along with proper connection string.

* Then the error raised:
The connection string for Key 'Tomato_Customer01' 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.

It seems that dynamically created ClientEdmKey was ignored or lost somewhere.

Is this a bug or I have missed something?


-------------



Replies:
Posted By: kimj
Date Posted: 24-Oct-2013 at 10:27am
Did you unzip and install the databases in the data subfolder?   My guess is that the GetConnectionString logic is failing because it can't access the tenant database, as the sample works fine for me.


Posted By: vecs
Date Posted: 25-Oct-2013 at 1:07am
[Solved]

I forgot to try common trick against strange application behavior.

After computer reboot, application works as expected.


-------------



Print Page | Close Window