0

So, i have my database sorted like:

Products_001 Products_002 Products_003

Let's say, if a customer logs in and his id is 001, he is only entitled to use the database-table products_001.

Can i dynamically create his model - entity using Asp.Net MVC, and how would i do this?

2 Answers 2

4
ProductsBase products = Activator.CreateInstance(
    "YourAssembly.Namespace", 
    "Products_" + Login.Id);

http://msdn.microsoft.com/en-us/library/d133hta4.aspx

You may need to have a base type/interface for your different product types

Sign up to request clarification or add additional context in comments.

2 Comments

Is this solution scalable? Eg. let's say the client uses this "custom model" for his website. => client 1 has website 1 and uses table product_001 - client 2 has website 2 and uses table product_002
thats probably another question, do you have this structure in place or are you considering it for a design?
0

NicoJuicy,

The way we handled this was to have a generic model (Using EF) and different DB's for each table. When the user logs in we bind the Model to the appropriate Db using the connection string and the user info.

If this sounds like what you want let me know and I will post more details.

Andrew

2 Comments

I think this solution is very resource intensive (correct me if i'm wrong)
I probably fudged the answer a bit as we have a multi tenancy app so as soon as they login we bind the EF Model to that clients db and that is it for the entire session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.