PJ on Development
Thoughts and babbling about software development. Visual Basic, .NET platform, web, etc.
Title: | Entity Model Code Generator |
Description: | Code generator for ADO.NET Entity Framework. |
Author: | Paulo Santos |
eMail: | pjondevelopment@gmail.com |
Environment: | Visual Studio 2008 SP1 |
Keywords: | Code Generation, CodeDom, Entities, Linq |
Entity Model Code Generator
- Download Source Code - 35,35 KB
DISCLAIMERThe Software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. |
||
Introduction
For most part of the last year (2008) I've been developing code using the ADO.NET Entity Framework, which sure is a very nice way to approach data driven applications.
However, as good as the Entity Framework is, it's far from perfect, specially when you start dealing with Web Services too.
For instance, when you create a web method that returns an instance of an entity, the XML generate is too complex, creating a lot of intermediate classes that has no purpose, or function. Those classes are created only because of the entity class inheritance hierarchy.
Taking the SampleEdmxCodeGenerator as the start point, I developed a code generator that create simple classes for each entity and the the appropriated converters.
For the code generation, it uses the EntityClassGenerator that handles all the entity classes creation, and uses the CodeDom to create the simple classes and the converters.
The namespace for the entities are specified by the Custom Tool Namespace
property of the file. If not informed it uses the RootNamespace
for VB projects and the Entity namespace for C# projects.
The simple classes are created on a sub-namespace SimpleClasses
, and the converters in a sub-namespace Converters
.