Print Page | Close Window

Multi database support in tenanted scenario

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=1978
Printed Date: 23-Jan-2026 at 1:19am


Topic: Multi database support in tenanted scenario
Posted By: sarmaad
Subject: Multi database support in tenanted scenario
Date Posted: 19-Jul-2010 at 5:26pm
I have two databases.
the first database holds admin records including user authentication details. the second database(s) holds user specific data.

I have two EF Models for each database with the same manager name, tested and working properly. I have implemented (CustomDataSourceKeyResolver) to retrieve connection strings based on the extension keys from admin database.

what I need to achieve is...

1. instantiate the EntityManager without any extensions (since we don't know the user just yet)
2. login and retrieve the user's extension key.
3. re-instantiate the manager with the specific extention..

I have implemented the above, but my question is... is there a better way to do that. since I re-instantiate the manager, I need to re-login the user... also, I don't feel its done right since the client app need to pass the extension key... can we implement this at the server side, rather than the client?

ultimately, i only need to login the user from the client, and the data connection string will be passed to client for the second database...

thoughts...

thanks



Replies:
Posted By: GregD
Date Posted: 21-Jul-2010 at 4:42pm
If you use one of the EM constructors that takes another EntityManager, you can avoid the redundant login, as the new EM will use the login credentials of the existing one.

It is the client app that is logging into the EntityService, so the EM needs to be instantiated (with the appropriate extension) client-side.


Posted By: sarmaad
Date Posted: 21-Jul-2010 at 5:07pm
I have tried this before...

ok, let see if we have this right...


var pm = new EntityManager();
if(pm.Login(loginCred))
{
    pm = new EntityManager(pm, true, "UserExtension", EntityServiceOption.UseDefaultService);
    var p = pm.Products.ToList();
}


I received an error "Padding is invalid and cannot be removed." when calling "Products.ToList()"


Posted By: kimj
Date Posted: 21-Jul-2010 at 5:34pm
The error you're seeing is due to a bug in version 6.0.3.1 with decrypting session bundles from another EnityServer.  There's an EntityServer for every data source extension, so the attempt to use the credentials from the first EntityManager/EntityServer fails with the second EntityManager/EntityServer for the new data source extension.   This problem was fixed in version 6.0.4.0, which should be available for download tomorrow.



Print Page | Close Window