0

I'm using Entity Framework with database-first because that was an easier learning curve. I've read that EF 7 will no longer use the EDMX file and that code-first will be the way to go.

I'm thinking of going ahead and converting to code-first now because my project is still relatively young, but am not sure how to get access to the metadata that EDMX provides. I use T4 templates extensively and need to get access to the metadata.

Is anyone using T4 templates with code-first, and if so how are you getting the metadata?

thanks,

john

John Mott
  • 445
  • 6
  • 12

2 Answers2

1

Use the EF Reverse POCO template available in the VS Gallery

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • That looks like something that will generate the POCO classes, but I don't see how it will provide access to metadata for t4 templates. – John Mott Nov 07 '14 at 23:53
  • Specifically the contents of EntityContainer, EdmProperty, NavigationProperty, EntityType and EdmItemCollection, defined in the System.Data.Metadata.Edm namespace. These classes are exposed to T4 templates through the MetadataLoader class. Their data is derived from the EDMX file. If there is not an EDMX file its not clear that these classes will be available. – John Mott Nov 08 '14 at 04:27
  • More specifically, if one is using code-first today are they able to use a T4 template and access these classes? – John Mott Nov 08 '14 at 04:28
0

The answer to the question is that metadata is available from the context object, as discussed in this post

How I can read EF DbContext metadata programmatically?

Community
  • 1
  • 1
John Mott
  • 445
  • 6
  • 12