Question

Is it possible to add some of property or variable or custom attribute to a particular column or navigation property within the EDMX designer so I can utilize it in my T4 template?

I want to be able to say (in my T4 template) "If this property is set, write an [XmlIgnore] attribute for this property."

I don't want to have to go into my T4 template and hard code property names.

Was it helpful?

Solution

Edmx can be extended by adding attributes or elements to existing elements. The only limitation is that the attribute cannot be in the namespaces EF is using or the empty namespace. For instance you can do something like this (with the Xml editor):

<Property Name="Value" Type="Int32" Nullable="false" ns:WriteIgnore="true" xmlns:ns="my-namespace-uri" />

Once the edmx is loaded to an item collection you will be able to access this custom property by reading MetadataProperties of the annotated item (in this case it would be the Property)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top