Interest in Codesmith templates that gen from an EDMX

Interest in Codesmith templates that gen from an EDMX

Old forum URL: forums.lhotka.net/forums/t/5496.aspx


zinovate posted on Tuesday, September 30, 2008

I am currently working on a new set of templates for CSLA 3.6 with Silverlight support with a MAJOR twist.

I plan on using the XML features in CodeSmith so that I can use an EDMX file as my data source.

My thoughts are, the designer allows us to abstract ourselves from the database slightly with the composite types etc...

Seems like a good fit and progress toward DDD for CSLA.

I thought about building a DSL toolkit much like the CSLAFactory but the Entity Framework designer seems like a nature replacement.

Does any one have interest in templates like this?

A little design, I am transforming the EDMX and extracting out the conceptual model section out of the EDMX for simplification. I then gen against the resulting XML. I plan on regenerating the intermediate XML for each generation.

You end up with tempate snippets like this:

  [Serializable]
  public class <%= EDMX.EntityTypes[ i ].Name %> : BusinessBase<<%= EDMX.EntityTypes[ i ].Name %>>

By stripping out the "extra" XML, the resulting templates are much simpler and readable:

Sample Public Property:

public <%= TypeConverter(EDMX.EntityTypes[ i ].Properties[i2].Type)%> CompanyName
    {
      get
      {
        return GetProperty(<%= EDMX.EntityTypes[ i ].Properties[i2].Name %>Property);
      }
      set
      {
        SetProperty(<%= EDMX.EntityTypes[ i ].Properties[i2].Name %>Property, value);
      }
    }  

The EDMX file also contains some DB contraints such as "MaxLength" for strings. If fields are nullable etc.... Perfect for Data Validation logic.

I also plan on using the Entity framework because I also use Vista DB and they plan on adding support for the EF in Q4. I'd like to be able to generate classes for both MSSQL use and VistaDB use or at least have portable templates. EF's data provider story is very compelling to me and my business needs. (Frictionless offline support)

I'd like to get a feeling for the demand for something like this from the community.
I would like to preface that I use CodeSmithPro 5.0. I know quite a few folks use the older free version of codesmith so I'm not sure how that will effect compatabilty for some.

lukky replied on Thursday, November 06, 2008

Hi,

I just came across this post.

This sounds like a very interesting idea. I'd like to know if this approach would also handle "child properties" (or navigation properties in EF parlance).

Keep us informed

Luc

dbilbey replied on Saturday, January 24, 2009

I came across this post while researching this exact idea. Have you gotten anywhere with it yet?

lukky replied on Saturday, January 24, 2009

Hi,

Actually, I've decided to put the lid on it for a little while.

I was thinking of using the CSLAContrib CodeSmith templates as my starting point, but then the CodeSmith developpers informed me that they're working on their own set of templates for CSLA 3.6.

Not that I find that Ricky Supit's templates (CSLAContrib) are bad, as a matter of fact I use them in a project as we speak, but the way they are divided makes it a bit difficult to edit them to your taste. Namely, if you know CodeSmith Studio, you know that it supports syntax highlighting and Intellisense, but not for include files, and Rick largely uses include files to split the templates in logical units. While discussing this issue with a CodeSmith developper, he told me they were going to rewrite the templates, but this time using Sub Templates, which will allow Syntax Highlighting and Intellisense.

Also, and this is a bigger issue, is the fact that EF doesn't seem to be used a lot in the CSLA crowd, and at this point in time, I have no solid example of how it should be used for each of the steroetypes defined by CSLA. My feeling is that it will probably look a lot like Linq to SQL, but until the CSLA community adopts EF, it will be difficult to create templates for it.

So, all that to say that I'm waiting to see the new CodeSmith templates before going further with this. On the other hand, I've been working on the "extract metadata" from EDMX file, and ran into some issues because of the XML Schema used by EDMX files. In any case, I don't see this as very difficult, and once the other pieces fall into place, it should be easy to integrate into existing templates.

Finally, what I'm learning out of all this will probably allow me to create another version of those templates, but this time extracting the metadata from the Linq to SQL mode (DBML files). So far, the XML schema definition for those files doesn't any problem in CodeSmith, and this project will probably come life before the EDMX based one.

Regards.

WillTartak replied on Saturday, May 22, 2010

Hi,

I was wondering if any of you (or anyone else) was made any progress on this approach?

Thanks,

\ ^ / i l l

zinovate replied on Tuesday, May 25, 2010

Nothing unfortunatly.

I was under a shipping deadline so I ended up going with Devforce for Silverlight and got the project out the door in no time.

I am still a big CSLA fan and love to see it's improvement.

lukky replied on Thursday, May 27, 2010

Hi all,

There is an ongoing effort to generate CSLA objects from an EF model at:

http://t4csla.codeplex.com/

It looks very promising !

 

bniemyjski replied on Thursday, June 24, 2010

Hello,

We are getting closer to this goal with our templates, but are still a ways out. We do have some people in our forums interested in adding support for this. maybe we could make this a team effort.

Thanks

-Blake Niemyjski

bniemyjski replied on Tuesday, August 03, 2010

 

Hello,

I'm working on updating the templates to add support for Views and Stored Procedures. I might add that we now support Silverlight 4! I also have a patch for using Linq-To-SQL as the data access layer. I'd be willing to through some effort at generating from an EDMX file, please contact me or CodeSmith support if you are interested.

Thanks

-Blake Niemyjski

 

Copyright (c) Marimer LLC