Database First without EDMX Designer
The current EDMX designer doesn't work well for enterprise scenarios - it becomes incredibly cumbersome as the number of entities grows. For example:
* It forces the developer to arrange entities visually - once you get over about 10 entities or complex relationships between them, it becomes difficult to do.
* It's difficult to find entities - rather than scan for them alphabetically, I need to scroll around a complex diagram I don't really want.
* The wizards get in the way - updating my model continually prompts me to modify my connection strings, I need to manually select the refresh tab for trivial database changes, and renaming database objects is incredibly difficult.
* I can't separate my "ORM structure" (EDMX) from my "entities". In the enterprise scenarios I'm working with, I need to put my POCO entities in a common class library and keep them structurally separate from the "database access logic".
At this point, it might be easy to suggest using Code First to working around this scenario - it allows me to declaratively describe my relationships through the fluent API and write my own POCO entities.
The problem is that there's a large performance hit with code first in complex scenarios - the lack of an EDMX means the model must be recreated each time the application is started. It also must look at the structure of the database itself, not just the code - meaning I take a large IO hit as well.
Our application has an SLA on request time - we simply can't wait 5-10 seconds for "code first" to build the model on the first request. IIS automatically recycles processes, meaning the performance hit comes up every 2-3 days. We want to keep app pool recycling in place for stability reasons.
What I've love to see is a "compiled database first" model - something where I can write my POCOs and Fluent API, then have EF pre-compile the EDMX rather than generate it at runtime.
Graphic designers, wizards, and auto-generated entities (ie/ current EDMX designer) are a deal-breaker for enterprise scenarios, but so is generating the complex model at runtime using Code First. No win.
Akash Kava commented
By looking at source, I realized that it is possible to dynamically build Metadata and supply it on constructor. Instead, we rely only on proper database structure with correct foreign key designed, and then we use text template to generate code, text template generates code as well as EDMX.
Here is the code to write text template,
= new EntityStoreSchemaGenerator(
generator.GenerateForeignKeyProperties = true;
= new List<EntityStoreSchemaFilterEntry>();
null, null, null,
Now you can inspect generator and then rebuild your text template. I will soon post this to codeplex.