I just would not attempt to build an application or framework that is
"generically applied to all reasonable-sized database-based apps and generate most of the code for you"!!
I, and many others, would build and do build frameworks for industy sectors and enterprises.
These frameworks have "best pratice" (very debatable term) princples and patterns applied so that developers can utilise them as TOOLS and still write code that meets business needs.
These can then become the standards for those enterprises and maybe even the industry sectors.
Affording newcomers, and old hands, in that enterprise the standards, the tools and the framework to codify the business logic and rules inside a scalable, extensibly, interfaced and may even service oriented frameworked solution.
Try reading more on private clouds (eg,Programming WCF, Juval Lowy, 3rd edition).
Your idea is good just not the bit about "generically applied" AND "generate most of the code".
Turn it into a framework without the code generators.
Code generators can cause more trouble than they are worth. eg when they contain a bug, when they need to be changed or extended.
I am sorry, but I think your approach is incorrect. No amount of code I post is going to change that.
There is no silver bullet that does all thing for all programmers.
Embedding yourself in good architecture that is based on prinplces, patterns and practices
( read "Design Patterns: Elements of Reusable Object-Oriented Software",Gof4; "Patterns of Enterprise Application Architecture",Martin Fowler; and even "Architecting Microsoft .NET Solutions for the Enterprise",Dino Esperato
Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives - Nick Rozanski