Hi,
I'm working on creating templates to generate CSLA Business Objects based on Entity Framework definition files.
I'm getting stuck at the very beginning because when I declare an XmlProperty and use the EF schema provided by Microsoft, the template won't compile.
Here's the important bit:
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %><%@ XmlProperty Name="EntityModel" Schema="Microsoft.Data.Entity.Design.Edmx.xsd" Optional="False" Category="Context" %>
And here's the compile error:
C:\Documents and Settings\Luc\My Documents\CodeSmith\Samples\v5.0\Templates\Examples\Xml\CSharp\EF.cst(7,0): error CS201: Unable to process XSD schema file ("C:\Documents and Settings\Luc\My Documents\CodeSmith\Samples\v5.0\Templates\Examples\Xml\CSharp\Microsoft.Data.Entity.Design.Edmx.xsd"): The element 'http://schemas.microsoft.com/ado/2006/04/edm/ssdl:Schema' is missing.
The schema for EF models is actually separated in many files. I have copied all the relevant files to the same folder as my template. The actual schema files can be found in the Visual Studio installation folder, for example:
C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
Has anyone tried this with CodeSmith ? Can CodeSmith work with "multi-file" schemas ?
I think that being able to generate CSLA classes directly from the EDMX file would be a very interesting feature for CodeSmith users. I know for sure that it would have been a very strong purchase incentive in my case, though I didn't need that to convince me
Now, I know I could achieve the same result without a schema file, but it sure would make life much easier.
Any hints ?
Thank you.
Luc Morin, T.P.http://www.stlm.ca
Just to bring this back to the top, I'd like to know what CodeSmith uses to generate the temporary class of an XmlProperty ?
Hello,
We use the .Net CodeDom and the .Net Framework API's to generate the temporary classes.Thanks-Blake Niemyjski
Blake Niemyjski CodeSmith Tools, LLC. Software Development Engineer Blog: http://windowscoding.com/blogs/blake/ .NetTiers team | Visit http://www.nettiers.com
Blake,
I just sent the files to Support under ticket number 101620.
I have included a minimalist template plus all the Entity Framework xsd files.
Luc
I am interested to hear how far you have gotten with your approach as I am currently investigating different options. I agree that a generation based on the entity framework looks like a promising approach. The other templates seem to create the business objects based on the database schema, which I dont think is ideal, as there are business objects which do not have a 1-to-1 correspondance to the database schema. DId you manage to set up a template baes on EF? Could we join efforts?
Thanks
Frank
I think he went the Linq to SQL route.Thanks-Blake Niemyjski
@Frank:
Unfortunately, I've been very taken by my current project and haven't had time to dig deeper.
I was stopped by some issues with XmlProperty in COdeSmith barfing on the XSD schema for EF.
On the other hand, I was able to "swallow" the Linq to SQL XSD schema, but since L2S is really a dead duck with MS, I feel I (we) should concentrate on EF.
I don't think I have had any replies from CodeSmith on the ticket I mention above, so I don't know the status of it. Maybe they did answer, I just don't recall
Anyway, the idea is simply that since EF Designer already captures all the entity definition + relations, it would be relatively easy to extract the necessary information and then generate Business Objects from it.
Once I'm finished with my current project (probably in september), I'll probably have time to dedicate to this.
Regards.
We still need to do some work on our end for CodeSmith to support generating from an edmx file with the XmlPropertyThanks-Blake Niemyjski
where are you guys with this? I am doing major development using EF4 and I was wondering if some kind of support for EF will be coming soon.
We still have not added support for this, it is on the backlog. We *should* be adding it when EF2.0 comes out. You could always load up an EDMX using .net logic inside of the template.
-Blake Niemyjski