If you read my previous blog post about the trials and tribulations of providing a connection string to the Entity Framework context in a multi-tenant SaaS app you will see that reflection magic was needed to get where I wanted to go.
Now for the next problem. I haven't solved this one, so please HELP.
The multi-tenant app implements the concept of what we call a portal. Each tenant has their own portal. Each customer is assigned a portalID when we set them up in the system. This portalID is passed into the login query string which is used by the app to identify which connection string should be used.
The connection strings are accessed via the portalID which is essentially a token. That GetConnectionString() method you saw in my context class needs to know the portalID in order to retrieve the correct connection string.
In our current code that portalID is put into the HttpContext with an HttpModule and can be read by our web page and passed into the BusinessRules on on to the DAL.
I would like to keep the Entity Framework models in their own project without any reference to the System.Web classes. So, how would I pass the portalID into the EF context so that it can be passed to the GetConnectionString helper.
Currently I have added a PortalID property to the EF object context but this means I have to set it in each DomainService class that we have. Once again because the LinktoEntitiesDomain class doesn't have any hooks at all.
Suggestion on how to do this, short of writing my own LinqToEntitiesDomaminService class?
Comments
Pingback
[...] RIA Services and EF4 in a multi-tennant app part two | No Long Days bob.archer.net/content/ria-services-and-ef4-multi-tennant-app-part-two – view page – cached If you read my previous blog post about the trials and tribulations of providing a connection string to the Entity Framework context in a multi-tenant SaaS app you will see that reflection magic was needed to get where I wanted to go. Tweets about this link Topsy.Data.Twitter.User['pilotbob'] = {"location":"Tampa, Florida, USA","photo":"http://a1.twimg.com/profile_images/52011836/gravatar_normal.JPG","name":"Bob Archer","url":"http://twitter.com/pilotbob","nick":"pilotbob","description":".Net developer, former VFP developer future Ruby developer.","influence":""}; pilotbob: “Blogged: RIA Services and EF4 in a multi-tennant app part two (http://bob.archer.net/node/33) ” 1 hour ago view tweet retweet Filter tweets [...]