Accessing Custom Properties from the CSDL Conceptual section of an EDMX within a T4 Template
-
Sunday, February 17, 2013 7:23 PM
I have custom properties withing the CSDL section of the EDMX so as to control the operation of a T4 Template.
But how do I access them in the T4 Template?
Does the API from EF.Utility.CS.ttinclude help me?I can write,
string inputFile = @"Model1.edmx"; EdmItemCollection ItemCollection = loader.CreateEdmItemCollection(inputFile); var abc = ItemCollection.GetItems<??Something??>().ToList();
but I don't know whether the custom properties are present in the EdmItemCollection?
Somehow I need to access the Schema, and then I could access the individual Xelements.
But re-parsing the EDMX file for this seems wasteful, and was looking for a better way.<edmx:ConceptualModels>
<Schema Namespace="Database1Model"> stuff removed for clarity <a:CslaUseDbContext xmlns:a="http://schemas.tempuri.com/CslaDesignerExtension">Yes</a:CslaUseDbContext>
</Schema>
</edmx:ConceptualModels>thanks
- Edited by jrad Sunday, February 17, 2013 7:26 PM
All Replies
-
Wednesday, February 20, 2013 3:20 AMModerator
Hi Jrad,
Welcome to the MSDN forum.
I am trying to involve a senior expert into your thread. Please wait for the response. Sorry for any inconvenience.
Best Regards,
Alexander Sun [MSFT]
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help. -
Wednesday, February 27, 2013 6:04 PM
Hi Jrad,
If you are able to express your custom properties as XML attributes rather than elements, then EF will parse those into the MetadataProperties collection on the corresponding metadata item. For example, you could add a custom attribute to the EntityContainer element in XML, then retrieve the EntityContainer metadata item using ItemCollection as you show above.
Cheers,
Andrew.
- Proposed As Answer by Glenn CondronMicrosoft Employee, Moderator Thursday, February 28, 2013 5:25 PM
- Marked As Answer by Alexander SunModerator Monday, March 11, 2013 4:13 PM

