Print Page | Close Window

EntityManager and specifying EntityConnection

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=1861
Printed Date: 21-Apr-2026 at 12:19pm


Topic: EntityManager and specifying EntityConnection
Posted By: MickyG
Subject: EntityManager and specifying EntityConnection
Date Posted: 06-Jun-2010 at 4:36am
I would like set the EntityConnection of my EntityManager.
How do I do that?

What I am trying to achieve, is I have a Windows service that hosts different worker threads. All the threads do not necessary point to the same database. Currently I am able to set the connection string on a thread by thread bases. I have a DevForce model and am trying to achieve the same thing, but because it inherits from EntityManager and EntityManager does not take a EntityConnection as part of the constructor I am struggling to figure out how I do this.

Any advice would be greatly appreciated.

Cheers
Mike



Replies:
Posted By: GregD
Date Posted: 07-Jun-2010 at 3:33pm
Three overloads of the EntityManager constructor take a DataSourceExtension parameter which will direct retrievals and saves to a specific instance of the database against whose schema a given entity was defined.  See the material on DataSourceKeys, DataSourceExtension, and DataSourceKeyResolvers in the Business Object Persistence_Advanced topic documents, and in the sample solutions at

     Learning Resources\040_BusObjPersistence\DataSourceKeys


Posted By: MickyG
Date Posted: 08-Jun-2010 at 3:54am
Thanks Greg, I have just this minute read the Dev Force with Ado.Net entity framework whitepaper and found the bit on the DataSourceKey extension.
 
Cheers
Mike



Print Page | Close Window