Single model in the same database multiple times

Topics: EF Runtime
Jan 24, 2013 at 2:06 PM
Edited Jan 24, 2013 at 2:07 PM

I've been reading up on the specs for adding Migrations Multi-tenancy in EF6 and I would like to propose to extend this support for having multiple identical models in the same database. We are developing a SaaS application where each tenant gets an identical model, but we would like to 'physically' seperate their data. I expect more people would benefit from this support.

The approach described in Rowan Miller's post supports our scenario quite nicely, but comes with the big disadvantage that we lose Migrations supports. Julie Lerman apparently got this scenario working in a convoluted way, but maybe this could be a good starting point to also support this scenario.

Coordinator
Jan 25, 2013 at 11:54 PM

Hi,

The name of 'Multi-Tenant Migrations' has caused some confusion - we've actually recently renamed the new feature to 'Multiple Contexts per Database' to help make it clearer what scenario we are targeting with that feature.

That said, your scenario is an important one and is tracked by this issue - http://entityframework.codeplex.com/workitem/54. I don't think we're going to be able to do much to improve it in EF6 (we're working on our last few features and then we're focusing on improving quality to get ready to RTM) . However, introducing DbModelBuilder.HasDefaultSchema will have made things a bit easier if you are separating by schema. I'm pretty sure you can get migrations to work in this scenario... but it would require some conditional code in the migrations code files. I'll play around with it and publish a new blog post :)

~Rowan

Jan 26, 2013 at 11:54 AM

Hi,

Thanks for the response, I'll track the item you mentioned and I'll be looking forward to the blog post :-)

Bjorn

Jan 27, 2013 at 10:36 PM
RoMiller wrote:

I don't think we're going to be able to do much to improve it in EF6 (we're working on our last few features and then we're focusing on improving quality to get ready to RTM).

This is off the topic of this thread, but as I see the thread already answered and see what you wrote: Is there any progress on stored procedures and functions for code first? Your roadmap says this is planned for EF6 but you haven't started yet.