1

For a business application, I am providing a base entity model. Thereafter the end user should be able to extend the model for his specific needs.

For the base model I want to use database-first approach. But I don't know how to accommodate for allowing user to extend it.

One part is to provide a UI for entity model editing and the other is to reflect the changes in the model and database thereafter. Please offer suggestions.

EDIT:
- Once the entity model is edited and saved, all EF facilities should work like before.
- Model update is conducted at the time of maintenance, i.e., it is not in use by business users.
- The affected project can be compiled and a new assembly can be produced and put to use.

1 Answer 1

2

It is not possible. When you modify entity model you must modify related entity classes (or create new ones) => you must recompile application or use some dynamic assemblies. Moreover there is no API to modify entity mapping at runtime so you are going to build new Entity designer.

It is generally same requirement as installing C# 2010 Express on client desktops and allowing them to modify, rebuild and redeploy your application.

Edit:

What you want requires:

  • Modifing EDMX - very complex XML file. Writing custom tool for that will be complex task. Moreover you will have to add logic wich will don't allow user to break the application.
  • Running T4 templates to generate new or modified entities.
  • Compiling application - what if user makes changes which break the build???
  • Redeploying DB - this itself is pretty bad taks because whole DB generation logic is Workflow running in Visual studio. Moreover you need another workflow which will be able to upgrade database - default one can only deploy new blank DB. Such workflow exists but it requires VS 2010 Premium or Ultimate.
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for replying. I guess I can remove one constraint from here, i.e., on change of my application model (this is done during application maintenance, which means no user can access the application at that time) I can compile the project that is affected and yield a new assembly. Now is there a way?
I added description to original answer.
This sounds tough. Firstly, T4 templates are usable only with Visual Studio and having Visual Studio on a production box would not be so graceful. So assuming that I create base entity using the database-first approach, can I implement the extensibility using the code-first approach? Is there a way that the model produced by the code-first approach be superimposed on the database-first model? And thereafter, would I be able to use a single context, such that I get an single context for all entities despite two approaches? Finally, can you think of a solution beyond EF?
Code first means writting the code to change mapping (model) and again you have a problem with upgrading existing db. I don't know what (and why) you want to achieve so I can't propose any other solution.

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.