I am using a T4 template that generates POCOs from EDMX files.
All underlying entities have their own schemas. That answer describes how you can extract the schema name from an EDMX:
StoreItemCollection sic;
loader.TryCreateStoreItemCollection(inputFile, out sic);
EntityContainer sicEntityContainer = sic.GetItems<EntityContainer>().First();
EntitySet eset = sicEntityContainer.GetEntitySetByName(code.Escape(entity), true);
string schemaName = eset.MetadataProperties["Schema"].Value.ToString();
If I look at the content of an EDMX file, I find out that there is a Schema attribute for each entity:
<EntitySet Name="Table_1"
EntityType="TestModel.Store.Table_1"
store:Type="Tables"
Schema="Blubb" />
At this point anything works fine and I can extract the schema name.
AND HERE IS THE PROBLEM:
Since one or two month Visual Studio 2010 adds a prefix called store to the Schema attribute of newer Entities in my model.
<EntitySet Name="Table_1"
EntityType="TestModel.Store.Table_1"
store:Type="Tables"
store:Schema="Blubb" />
So I cannot extract the schema by using the logic of the upper linked article.
I have to remove these prefixes with a text editor manually, so anything can be worked fine.
My questions:
You need to prefix the "Type/Schema" with its namespace
ie:
eset.MetadataProperties["http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator:Type"].Value.ToString();
eset.MetadataProperties["http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator:Schema"].Value.ToString();