获取表格和关系

时间:2011-09-21 00:21:55

标签: .net entity-framework edmx

有没有办法使用MetadataLoader从EDMX获取表和关系列表?

1 个答案:

答案 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>())
{
    ...
}