I'm using CsdlReader in C# to parse a csdl. The whole XML file is as follows:
<Schema
xmlns=\"http://schemas.microsoft.com/ado/2008/09/edm\"
xmlns:edm_annotation=\"http://schemas.microsoft.com/ado/2009/02/edm/annotation\"
xmlns:bi=\"http://schemas.microsoft.com/sqlbi/2010/10/edm/extensions\" bi:Version=\"1.0\" Namespace=\"Sandbox\">
<EntityContainer Name=\"Sandbox\">
<EntitySet Name=\"CountryRegions\" EntityType=\"Sandbox.CountryRegions\">
<bi:EntitySet />
</EntitySet>
<EntitySet Name=\"Editions\" EntityType=\"Sandbox.Editions\">
<bi:EntitySet />
</EntitySet>
<EntitySet Name=\"Medals\" EntityType=\"Sandbox.Medals\">
<bi:EntitySet />
</EntitySet>
<EntitySet Name=\"Medalists\" EntityType=\"Sandbox.Medalists\">
<bi:EntitySet />
</EntitySet>
<EntitySet Name=\"MedalClasses\" EntityType=\"Sandbox.MedalClasses\">
<bi:EntitySet Hidden=\"true\" />
</EntitySet>
<AssociationSet Name=\"Editions_CountryRegions_CountryRegions_Country_Region\" Association=\"Sandbox.Editions_CountryRegions_CountryRegions_Country_Region\">
<End EntitySet=\"Editions\" />
<End EntitySet=\"CountryRegions\" />
<bi:AssociationSet State=\"Inactive\" />
</AssociationSet>
<AssociationSet Name=\"Medals_CountryRegions_CountryRegions_IOC_Code\" Association=\"Sandbox.Medals_CountryRegions_CountryRegions_IOC_Code\">
<End EntitySet=\"Medals\" />
<End EntitySet=\"CountryRegions\" />
<bi:AssociationSet />
</AssociationSet>
<AssociationSet Name=\"Medals_Editions_Editions_Year\" Association=\"Sandbox.Medals_Editions_Editions_Year\">
<End EntitySet=\"Medals\" />
<End EntitySet=\"Editions\" />
<bi:AssociationSet />
</AssociationSet>
<AssociationSet Name=\"Medals_MedalClasses_MedalClasses_Class\" Association=\"Sandbox.Medals_MedalClasses_MedalClasses_Class\">
<End EntitySet=\"Medals\" />
<End EntitySet=\"MedalClasses\" />
<bi:AssociationSet />
</AssociationSet>
<AssociationSet Name=\"Medalists_Medals_Medals_Medal_ID\" Association=\"Sandbox.Medalists_Medals_Medals_Medal_ID\">
<End EntitySet=\"Medalists\" />
<End EntitySet=\"Medals\" />
<bi:AssociationSet />
</AssociationSet>
<bi:EntityContainer Caption=\"IN_Olympics\" Culture=\"en-US\">
<bi:CompareOptions IgnoreCase=\"true\" />
</bi:EntityContainer>
</EntityContainer>
<EntityType Name=\"CountryRegions\">
<Key>
<PropertyRef Name=\"IOC_Code\" />
</Key>
<Property Name=\"RowNumber\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Hidden=\"true\" Contents=\"RowNumber\" Stability=\"RowNumber\" />
</Property>
<Property Name=\"Country_Region\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\" Nullable=\"false\">
<bi:Property Caption=\"Country/Region\" ReferenceName=\"Country/Region\" Contents=\"Country\" />
</Property>
<Property Name=\"IOC_Code\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\" Nullable=\"false\">
<bi:Property Caption=\"IOC Code\" Hidden=\"true\" ReferenceName=\"IOC Code\" GroupingBehavior=\"GroupOnEntityKey\" />
</Property>
<Property Name=\"ISO_Code\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"ISO Code\" Hidden=\"true\" ReferenceName=\"ISO Code\" />
</Property>
<Property Name=\"Residency\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property />
</Property>
<Property Name=\"Flag\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Contents=\"ImageUrl\" />
</Property>
<Property Name=\"Continent\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Contents=\"Continent\" />
</Property>
<Property Name=\"Heavyweight\" Type=\"Boolean\">
<bi:Property FormatString=\""TRUE";"TRUE";"FALSE"\" />
</Property>
<Property Name=\"medal_rank\" Type=\"Int64\">
<bi:Measure Caption=\"medal rank\" ReferenceName=\"medal rank\" />
</Property>
<bi:EntityType>
<bi:DisplayKey>
<bi:MemberRef Name=\"Country_Region\" />
</bi:DisplayKey>
<bi:DefaultDetails>
<bi:MemberRef Name=\"Flag\" />
<bi:MemberRef Name=\"Country_Region\" />
</bi:DefaultDetails>
<bi:DefaultImage>
<bi:MemberRef Name=\"Flag\" />
</bi:DefaultImage>
</bi:EntityType>
</EntityType>
<EntityType Name=\"Editions\">
<Key>
<PropertyRef Name=\"Year\" />
</Key>
<Property Name=\"RowNumber\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Hidden=\"true\" Contents=\"RowNumber\" Stability=\"RowNumber\" />
</Property>
<Property Name=\"Host_City\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Host City\" ReferenceName=\"Host City\" Contents=\"City\" />
</Property>
<Property Name=\"Year\" Type=\"Int64\" Nullable=\"false\">
<bi:Property DefaultAggregateFunction=\"None\" GroupingBehavior=\"GroupOnEntityKey\" />
</Property>
<Property Name=\"Host_Country_Region\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Host Country/Region\" ReferenceName=\"Host Country/Region\" Contents=\"Country\" />
</Property>
<Property Name=\"Name\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property />
</Property>
<Property Name=\"Host_Continent\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Host Continent\" ReferenceName=\"Host Continent\" Contents=\"Continent\" />
</Property>
<Property Name=\"Olympic_Name\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Olympic Name\" ReferenceName=\"Olympic Name\" />
</Property>
<Property Name=\"Olympic_Full_Name\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Olympic Full Name\" ReferenceName=\"Olympic Full Name\" />
</Property>
<Property Name=\"Sum_of_Year\" Type=\"Int64\">
<bi:Measure Caption=\"Sum of Year\" ReferenceName=\"Sum of Year\" IsSimpleMeasure=\"true\" />
</Property>
<NavigationProperty Name=\"CountryRegions_Country_Region\" Relationship=\"Sandbox.Editions_CountryRegions_CountryRegions_Country_Region\" FromRole=\"Editions_Host_Country_Region\" ToRole=\"CountryRegions_Country_Region\">
<bi:NavigationProperty ReferenceName=\"CountryRegions_Country/Region\" />
</NavigationProperty>
<bi:EntityType>
<bi:DisplayKey>
<bi:MemberRef Name=\"Name\" />
</bi:DisplayKey>
</bi:EntityType>
</EntityType>
<EntityType Name=\"Medals\">
<Key>
<PropertyRef Name=\"Medal_ID\" />
</Key>
<Property Name=\"RowNumber\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Hidden=\"true\" Contents=\"RowNumber\" Stability=\"RowNumber\" />
</Property>
<Property Name=\"Medal_ID\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Caption=\"Medal ID\" Hidden=\"true\" ReferenceName=\"Medal ID\" GroupingBehavior=\"GroupOnEntityKey\" />
</Property>
<Property Name=\"Year\" Type=\"Double\">
<bi:Property Hidden=\"true\" />
</Property>
<Property Name=\"Sport\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property />
</Property>
<Property Name=\"Discipline\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property />
</Property>
<Property Name=\"NOC\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Hidden=\"true\" />
</Property>
<Property Name=\"Event\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property />
</Property>
<Property Name=\"Event_Gender_raw\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Event Gender raw\" ReferenceName=\"Event Gender raw\" />
</Property>
<Property Name=\"Class\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property>
<bi:OrderBy>
<bi:PropertyRef Name=\"Class_Rank\" />
</bi:OrderBy>
</bi:Property>
</Property>
<Property Name=\"Description\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property />
</Property>
<Property Name=\"Class_Rank\" Type=\"Int64\">
<bi:Property Caption=\"Class Rank\" Hidden=\"true\" ReferenceName=\"Class Rank\" />
</Property>
<Property Name=\"Event_Gender\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Event Gender\" ReferenceName=\"Event Gender\" />
</Property>
<Property Name=\"Olympic_Year\" Type=\"Int64\">
<bi:Property Caption=\"Olympic Year\" ReferenceName=\"Olympic Year\" DefaultAggregateFunction=\"None\" />
</Property>
<Property Name=\"Country_Region\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Country/Region\" ReferenceName=\"Country/Region\" Contents=\"Country\" />
</Property>
<Property Name=\"medal_growth__vs_previous_Olympics_\" Type=\"Double\">
<bi:Measure Caption=\"medal growth (vs previous Olympics)\" ReferenceName=\"medal growth (vs previous Olympics)\" FormatString=\"0.0 %;-0.0 %;0.0 %\" />
</Property>
<Property Name=\"Cumulative_Medal_Count\" Type=\"Int64\">
<bi:Measure Caption=\"Cumulative Medal Count\" ReferenceName=\"Cumulative Medal Count\" FormatString=\"#,0\" />
</Property>
<Property Name=\"Cumulative_Event_Count\" Type=\"Int64\">
<bi:Measure Caption=\"Cumulative Event Count\" ReferenceName=\"Cumulative Event Count\" />
</Property>
<Property Name=\"Years_Since_First_Olympic_Win\" Type=\"Int64\">
<bi:Measure Caption=\"Years Since First Olympic Win\" ReferenceName=\"Years Since First Olympic Win\" />
</Property>
<Property Name=\"Percent_of_Total_Medals_in_Sport\" Type=\"Double\">
<bi:Measure Caption=\"Percent of Total Medals in Sport\" ReferenceName=\"Percent of Total Medals in Sport\" FormatString=\"0.00 %;-0.00 %;0.00 %\" />
</Property>
<Property Name=\"Medal_Weight\" Type=\"Double\">
<bi:Measure Caption=\"Medal Weight\" ReferenceName=\"Medal Weight\" />
</Property>
<Property Name=\"Medal_Count\" Type=\"Int64\">
<bi:Measure Caption=\"Medal Count\" ReferenceName=\"Medal Count\" FormatString=\"#,0\" />
</Property>
<NavigationProperty Name=\"CountryRegions_IOC_Code\" Relationship=\"Sandbox.Medals_CountryRegions_CountryRegions_IOC_Code\" FromRole=\"Medals_NOC\" ToRole=\"CountryRegions_IOC_Code\">
<bi:NavigationProperty ReferenceName=\"CountryRegions_IOC Code\" />
</NavigationProperty>
<NavigationProperty Name=\"Editions_Year\" Relationship=\"Sandbox.Medals_Editions_Editions_Year\" FromRole=\"Medals_Year\" ToRole=\"Editions_Year\">
<bi:NavigationProperty />
</NavigationProperty>
<NavigationProperty Name=\"MedalClasses_Class\" Relationship=\"Sandbox.Medals_MedalClasses_MedalClasses_Class\" FromRole=\"Medals_Class\" ToRole=\"MedalClasses_Class\">
<bi:NavigationProperty />
</NavigationProperty>
<bi:EntityType>
<bi:DisplayKey>
<bi:MemberRef Name=\"Description\" />
</bi:DisplayKey>
<bi:DefaultDetails>
<bi:MemberRef Name=\"Discipline\" />
<bi:MemberRef Name=\"Event\" />
<bi:MemberRef Name=\"Event_Gender\" />
<bi:MemberRef Name=\"Year\" />
<bi:MemberRef Name=\"Class\" />
<bi:MemberRef Name=\"Olympic_Year\" />
<bi:MemberRef Name=\"Country_Region\" />
</bi:DefaultDetails>
</bi:EntityType>
</EntityType>
<EntityType Name=\"Medalists\">
<Key>
<PropertyRef Name=\"Medalist_ID\" />
</Key>
<Property Name=\"RowNumber\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Hidden=\"true\" Contents=\"RowNumber\" Stability=\"RowNumber\" />
</Property>
<Property Name=\"Medalist_ID\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Caption=\"Medalist ID\" Hidden=\"true\" ReferenceName=\"Medalist ID\" />
</Property>
<Property Name=\"Medal_ID\" Type=\"Int64\">
<bi:Property Caption=\"Medal ID\" Hidden=\"true\" ReferenceName=\"Medal ID\" />
</Property>
<Property Name=\"Athlete_Name_Sort_Order\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Athlete Name Sort Order\" Hidden=\"true\" ReferenceName=\"Athlete Name Sort Order\" />
</Property>
<Property Name=\"Athlete_Name\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Athlete Name\" ReferenceName=\"Athlete Name\" />
</Property>
<Property Name=\"Medal_Class\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Medal Class\" ReferenceName=\"Medal Class\" />
</Property>
<Property Name=\"Athlete_Full_Last_Name\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Athlete Full Last Name\" Hidden=\"true\" ReferenceName=\"Athlete Full Last Name\" />
</Property>
<Property Name=\"Athlete_Alias\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Athlete Alias\" ReferenceName=\"Athlete Alias\" />
</Property>
<Property Name=\"Athlete_Last_Name\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\">
<bi:Property Caption=\"Athlete Last Name\" ReferenceName=\"Athlete Last Name\" />
</Property>
<Property Name=\"Sum_of_Medalist_ID\" Type=\"Int64\">
<bi:Measure Caption=\"Sum of Medalist ID\" ReferenceName=\"Sum of Medalist ID\" IsSimpleMeasure=\"true\" />
</Property>
<Property Name=\"Count_of_Athlete_Name\" Type=\"Int64\">
<bi:Measure Caption=\"Count of Athlete Name\" ReferenceName=\"Count of Athlete Name\" IsSimpleMeasure=\"true\" />
</Property>
<NavigationProperty Name=\"Medals_Medal_ID\" Relationship=\"Sandbox.Medalists_Medals_Medals_Medal_ID\" FromRole=\"Medalists_Medal_ID\" ToRole=\"Medals_Medal_ID\">
<bi:NavigationProperty ReferenceName=\"Medals_Medal ID\" />
</NavigationProperty>
<bi:EntityType>
<bi:DefaultDetails>
<bi:MemberRef Name=\"Athlete_Name\" />
</bi:DefaultDetails>
</bi:EntityType>
</EntityType>
<EntityType Name=\"MedalClasses\">
<Key>
<PropertyRef Name=\"v__XL_RowNumber\" />
</Key>
<Property Name=\"Class\" Type=\"String\" MaxLength=\"Max\" Unicode=\"true\" FixedLength=\"false\" Nullable=\"false\">
<bi:Property />
</Property>
<Property Name=\"Class_Rank\" Type=\"Int64\">
<bi:Property Caption=\"Class Rank\" ReferenceName=\"Class Rank\" />
</Property>
<Property Name=\"v__XL_RowNumber\" Type=\"Int64\" Nullable=\"false\">
<bi:Property Caption=\"__XL_RowNumber\" Hidden=\"true\" ReferenceName=\"__XL_RowNumber\" Contents=\"RowNumber\" Stability=\"RowNumber\" />
</Property>
<bi:EntityType />
</EntityType>
<Association Name=\"Editions_CountryRegions_CountryRegions_Country_Region\">
<End Role=\"Editions_Host_Country_Region\" Type=\"Sandbox.Editions\" Multiplicity=\"*\" />
<End Role=\"CountryRegions_Country_Region\" Type=\"Sandbox.CountryRegions\" Multiplicity=\"0..1\" />
</Association>
<Association Name=\"Medals_CountryRegions_CountryRegions_IOC_Code\">
<End Role=\"Medals_NOC\" Type=\"Sandbox.Medals\" Multiplicity=\"*\" />
<End Role=\"CountryRegions_IOC_Code\" Type=\"Sandbox.CountryRegions\" Multiplicity=\"0..1\" />
</Association>
<Association Name=\"Medals_Editions_Editions_Year\">
<End Role=\"Medals_Year\" Type=\"Sandbox.Medals\" Multiplicity=\"*\" />
<End Role=\"Editions_Year\" Type=\"Sandbox.Editions\" Multiplicity=\"0..1\" />
</Association>
<Association Name=\"Medals_MedalClasses_MedalClasses_Class\">
<End Role=\"Medals_Class\" Type=\"Sandbox.Medals\" Multiplicity=\"*\" />
<End Role=\"MedalClasses_Class\" Type=\"Sandbox.MedalClasses\" Multiplicity=\"0..1\" />
</Association>
<Association Name=\"Medalists_Medals_Medals_Medal_ID\">
<End Role=\"Medalists_Medal_ID\" Type=\"Sandbox.Medalists\" Multiplicity=\"*\" />
<End Role=\"Medals_Medal_ID\" Type=\"Sandbox.Medals\" Multiplicity=\"0..1\" />
</Association>
</Schema>
And this is my code:
CsdlReader.TryParse(schemaReaders, out edmModel, out edmErrors)
As you can see. Role
is an attribute of End
. However, it seems that I am unable to parse that XML. And I have errors like this in edmErrors:
{MissingAttribute : Required schema attribute 'Role' is not present on element 'End'. : (0, 0)}
The message tells me that Role
is missing, but I do have that in my csdl.
It is down to the OData version. Older versions generate AssociationSet without Role, a newer version of CsdlReader expects Role to be there. Current is 4.0 (see http://www.odata.org/documentation/ ).
You can see the version of your CSDL by looking at the properties of the assembly. If you obtained your XML using GetSchemaDataSet then you can request the right version in the RestrictionList parameter. This only shows it in XMLA but the params are the same. (https://learn.microsoft.com/en-us/sql/analysis-services/schema-rowsets/xml/discover-csdl-metadata-rowset )