EDMX XML Namespaces issue

Topics: EF Designer
Jun 4, 2013 at 7:34 AM
Hi, i've installed the new EF 6 beta 1 Tooling on VS2012 and looks like something is changed, in fact new tooling cannot validate an edmx even if previous version did.

e.g.
<edmx:StorageModels>
      <Schema xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" 
Namespace="MyTestModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
will result in Error 10027: The XML namespace for the conceptual model's Schema element is not supported on this project's target framework version.

Looks like the new tooling isn't able to accept EdmVersion 3 edmx, in fact creating a new empty model will use EdmVersion 2 by default.

Am I missing something?

Thanks, Max
Jun 4, 2013 at 3:55 PM
Hi Max,

Can you paste the full edmx file? I suspect that for some reason the edmx prefix is bound to a non-v3 namespace uri for the edmx format and therefore v3 schemas under non-v3 edmx root are rejected. Can you provide the steps to reproduce the issue?

Thanks,
Pawel
Jun 4, 2013 at 7:18 PM
Hi Pawel,
here it is
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Namespace="MyTestModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
        <EntityContainer Name="MyTestModelStoreContainer">
          <EntitySet Name="Parent" Table="Parent" store:Name="Parent" Schema="dbo" store:Type="Tables" EntityType="MyTestModel.Store.Parent" />
          <EntitySet Name="Child" Table="Child" store:Name="Child" Schema="dbo" store:Type="Tables" EntityType="MyTestModel.Store.Child" />
          <AssociationSet Name="ChildParent" Association="MyTestModel.Store.ChildParent">
            <End Role="Parent" EntitySet="Parent" />
            <End Role="Child" EntitySet="Child" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="Parent">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="Id" Type="int" Nullable="false" />
          <Property Name="Name" Type="nvarchar" Nullable="true" />
        </EntityType>
        <EntityType Name="Child">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="Id" Type="int" Nullable="false" />
          <Property Name="Name" Type="nvarchar" Nullable="true" />
          <Property Name="Parent_Id" Type="int" Nullable="false" />
        </EntityType>
        <Association Name="ChildParent">
          <End Multiplicity="1" Role="Parent" Type="MyTestModel.Store.Parent" />
          <End Multiplicity="*" Role="Child" Type="MyTestModel.Store.Child" />
          <ReferentialConstraint>
            <Principal Role="Parent">
              <PropertyRef Name="Id" />
            </Principal>
            <Dependent Role="Child">
              <PropertyRef Name="Parent_Id" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" Namespace="MyTestModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
        <EntityContainer Name="MyTestModelEntities" annotation:LazyLoadingEnabled="false">
          <EntitySet Name="ParentSet" EntityType="MyTestModel.Parent" />
          <EntitySet Name="ChildSet" EntityType="MyTestModel.Child" />
          <AssociationSet Name="ChildParent" Association="MyTestModel.ChildParent">
            <End Role="Parent" EntitySet="ParentSet" />
            <End Role="Child" EntitySet="ChildSet" />
          </AssociationSet>
        </EntityContainer>
        <EntityType Name="Parent">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="Id" Type="Int32" Nullable="false" />
          <Property Name="Name" Type="String" Nullable="true" FixedLength="false" />
          <NavigationProperty Relationship="MyTestModel.ChildParent" FromRole="Parent" ToRole="Child" Name="Child" />
        </EntityType>
        <EntityType Name="Child">
          <Key>
            <PropertyRef Name="Id" />
          </Key>
          <Property Name="Id" Type="Int32" Nullable="false" />
          <Property Name="Name" Type="String" Nullable="true" FixedLength="false" />
          <Property Name="ParentId" Type="Int32" Nullable="false" />
          <NavigationProperty Relationship="MyTestModel.ChildParent" FromRole="Child" ToRole="Parent" Name="Parent" />
        </EntityType>
        <Association Name="ChildParent">
          <End Role="Parent" Type="MyTestModel.Parent" Multiplicity="1">
            <OnDelete Action="Cascade" />
          </End>
          <End Role="Child" Type="MyTestModel.Child" Multiplicity="*" />
          <ReferentialConstraint>
            <Principal Role="Parent">
              <PropertyRef Name="Id" />
            </Principal>
            <Dependent Role="Child">
              <PropertyRef Name="ParentId" />
            </Dependent>
          </ReferentialConstraint>
        </Association>
      </Schema>
    </edmx:ConceptualModels>
    <!-- C-S mapping content -->
    <edmx:Mappings>
      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
        <EntityContainerMapping StorageEntityContainer="MyTestModelStoreContainer" CdmEntityContainer="MyTestModelEntities">
          <EntitySetMapping Name="ParentSet">
            <EntityTypeMapping TypeName="MyTestModel.Parent">
              <MappingFragment StoreEntitySet="Parent">
                <ScalarProperty Name="Id" ColumnName="Id" />
                <ScalarProperty Name="Name" ColumnName="Name" />
              </MappingFragment>
            </EntityTypeMapping>
          </EntitySetMapping>
          <EntitySetMapping Name="ChildSet">
            <EntityTypeMapping TypeName="MyTestModel.Child">
              <MappingFragment StoreEntitySet="Child">
                <ScalarProperty Name="Id" ColumnName="Id" />
                <ScalarProperty Name="Name" ColumnName="Name" />
                <ScalarProperty Name="ParentId" ColumnName="Parent_Id" />
              </MappingFragment>
            </EntityTypeMapping>
          </EntitySetMapping>
        </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>
  </edmx:Runtime>
  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
  <edmx:Designer>
    <edmx:Connection>
      <DesignerInfoPropertySet xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
      </DesignerInfoPropertySet>
    </edmx:Connection>
    <edmx:Options>
      <DesignerInfoPropertySet xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
        <DesignerProperty Name="EnablePluralization" Value="false" />
        <DesignerProperty Name="ValidateOnBuild" Value="false" />
        <DesignerProperty Name="CodeGenerationStrategy" Value="None" />
      </DesignerInfoPropertySet>
    </edmx:Options>
    <!-- Diagram content (shape and connector positions) -->
    <edmx:Diagrams />
  </edmx:Designer>
</edmx:Edmx>
Maybe it's my mistake, just switched the target framework to 4.5 the designer gives no error, targeting framework 4 gives the 3 errors listed above

Error 1 Error 10027: The XML namespace for the conceptual model's Schema element is not supported on this project's target framework version. C:\Code\tmp\EDMX\ConsoleApplication1\ConsoleApplication1\Model1.edmx 47 7 ConsoleApplication1
Error 2 Error 10028: The XML namespace for the storage model's Schema element is not supported on this project's target framework version. C:\Code\tmp\EDMX\ConsoleApplication1\ConsoleApplication1\Model1.edmx 7 7 ConsoleApplication1
Error 3 Error 10029: The XML namespace for the Mapping element is not supported on this project's target framework version. C:\Code\tmp\EDMX\ConsoleApplication1\ConsoleApplication1\Model1.edmx 91 7 ConsoleApplication1

Thanks, Max
Jun 4, 2013 at 7:41 PM
Hi Max,

Validation is something we are still working on. At the moment we use EF5 to validate models and therefore when you target .NET Framework 4 v3 schemas are not recognized and you get the errors. Notice that if you tried creating a new project targeting .NET Framework 4 you would not be able to select EF6 and you would get v2 schemas. This is to prevent from the kind of errors you are seeing. We don't do anything when retargeting so if you create a project targeting .NET Framework 4.5 on EF6 and then retarget the project to .NET Framework 4 you will end up having a v3 schemas on .NET Framework 4. As I mentioned we are working on enabling this scenario.

Thanks,
Pawel