I have annotated my Entity Framework Code First objects with some extra metadata, such as the DataTypeAttribute or possibly new, custom attributes. A version of this code (from http://www.minddriven.de/index.php/technology/dot-net/web/asp-net-mvc/check-data-annotations-from-code) works well to read the attributes once I have the EF Code First POCO object's Type object.
However, I cannot figure out how to go from the MetadataWorkspace, where I find all the entities:
ObjectContext objContext = ((IObjectContextAdapter)this).ObjectContext;
MetadataWorkspace mw = objContext.MetadataWorkspace;
var entities = mw.GetItems<EntityType>(DataSpace.OSpace);
to the POCO class Types I need to reflect on the Attributes.
How do I get from an EntityType to the POCO object or its proxy? Or alternatively, how can I find all the POCO objects in the context without GetItems()?
Relevant Links:
There might be a direct way to do this but you can get the type from the full name
var types = from entity in entities
select Type.GetType(entity.FullName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With