开发者

Is it possible to generate XML from a EDMX model?

I'm generating my POCO's from edmx model, and would l开发者_如何学运维ike to know if its possible to make use of the neat codegen features of Entity Framework to create my an xml document along with the POCO (which is needed for my project).


You can generate an XML document in Visual Studio using T4 templates.

In Visual Studio, a T4 text template is a mixture of text blocks and control logic that can generate a text file. The control logic is written as fragments of program code in Visual C# or Visual Basic. The generated file can be text of any kind, such as a Web page, or a resource file, or program source code in any language.

But you should note that the EDMX file itself is an XML document.

  • Right click on your Model.edmx file
  • 'Open With...'
  • Choose 'XML (Text) Editor'

There are three main sections to the file

  • StorageModels - describes that database
  • ConceptualModels - describes your code and objects
  • Mappings - describes how the two models relate

Look at whether the standard EDMX file contains the type of information you want. If not, parse and shred it using T4 to extract the information you're looking for.


No need to parse the EDMX file, use TiraggoEdmx, you can install it via NuGet. See http://brewdawg.github.io/Tiraggo.Edmx/ it serves up all of the metadata from your EDMX files that Microsoft hides from you, very simple, works great. I wrote it but it's 100% free, even comes with a sample POCO template.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜