Is there a way to get ModelMetadata.Properties for ModelMetadata.RelatedEntities?

I read in the Microsoft.AspNet.Scaffolding.Core.Metadata namespace; however, I'm new to this object model, and maybe I'm missing something. I am creating T4 text templates and would like to automatically generate output for the associated model data. Something similar to ModelMetadata.RelatedModelMetadata.ModelMetadata.PropertyMetadata ie

foreach (PropertyMetadata property in ModelMetadata.Properties) {
  if (property.IsAssociation) {
    RelatedModelMetadata relatedModel = property.RelatedModel
    foreach (PropertyMetadata relatedProperty in relatedModel.Properties) {
      // Do Something
    }
  }
}

This, of course, will not work, since the RelatedModelMetadata object does not have a collection of properties; in fact, all relatedModelMetadata properties are strings.

Any hints are tricks that you might appreciate.

Thank!

+4
source share
1

Model.ModelMetadata.Navigations. RelatedModelMetadata... "" ... , , , .

@foreach (var property in Model.ModelMetadata.Navigations)
{
   //I do what I want!
}

property

  • AssociationPropertyName:
  • DisplayPropertyName:
  • EntitySetName:
  • ForeignKeyPropertyNames:
  • PrimaryKeyNames:
  • ShortTypeName:
  • Name:
-2

All Articles