tags:

views:

19

answers:

1

We are designing our new product, which will include multi-tenancy. It will be written in ASP.NET and C#, and may be hosted on Windows Azure or some other Cloud hosting solution.

We’ve been looking at MVC and other technologies and, to be honest, we’re getting bogged down in various acronyms (MVC, EF, WCF etc. etc.).

A particular requirement of our application is causing a headache – the users will be able to add fields to the database, or even create a whole new module.

As a result, each tenant would have a database with a different structure to every other tenant using the system. We envisage that every tenant will have their own database, rather than sharing a database.

(Adding fields etc. to the system will be accomplished using a web interface).

All well and good, but the problem comes when creating a data model for MVC. Modifying a data model programmatically to add a field to a table seems to be impossible, according to this link:

Create EDM during runtime?

This is a major headache for us. Even if we don’t use MVC, I think we’d still want to create a data model (perhaps for used with LINQ to SQL).

We’re considering having a table with loads of fields in it, and instead of adding fields to the database we allocate an existing field in the table when the user wants to add a field to his form. Not sure I like that idea, though.

Of course, we don’t have to use MVC or Entity Framework, but it appears to me that these are the kind of technologies that Microsoft would steer us towards for future development.

Any thoughts? I’m assuming that we’re not the first people in the world to consider this idea of a user-customisable application.

A: 

Just off the top of my head it sounds like a bad idea to allow users to change the database schema. I think you are missing a layer of abstraction. In my mind, it would be more correct to use the database to hold data that describes the format of a customer's data. The actual data would then be saved in a text column as xml, including version information. This solution may not fit your needs, but I don't know the details of your project. So just consider it my 5 cents.

klausbyskov
I get where you're coming from - allowing the user to change the schema is the root of the problem. However, I don't feel that storing the users data as xml in a field is a viable solution - how would you query that data?
Matt
Our initial thought was to store the data abstraction or metadata in xml, but store the data in sql server. Which leads us to the problem of how to create a data model at runtime.
Matt
@Matt, I was thinking that if you're going to use the SqlServer Azure data store, that you could do xml queries on those custom fields.
klausbyskov