有没有办法使用MetadataLoader从EDMX获取表和关系列表?
答案 0 :(得分:4)
试试这个:
MetadataWorkspace metadataWorkspace = null;
bool allMetadataLoaded = loader.TryLoadAllMetadata(inputFile, out metadataWorkspace);
StoreItemCollection itemCollection = (StoreItemCollection)metadataWorkspace.GetItemCollection(DataSpace.SSpace);
// Tables
foreach (var entity in itemCollection.GetItems<EntityType>())
{
...
}
// Relations
foreach (var association in itemCollection.GetItems<AssociationType>())
{
...
}