locked
Help with EDMX file error message RRS feed

  • Question

  • Hi,

    I'm currently writing a project that is updating the EDMX file through code using XLINQ. I'm creating a * to * relationship at present, and after what appears to be successful creation (the designer loads the model happily and the relationship is defined) I still get the following error when opening up in XML mode or building the project (the project succeeds in building, but I'd like to get rid of the error):

    Error 2007: The table 'ParentObject_ChildObject' specified as part of this MSL does not exist in MetadataWorkspace.

    Below is my EDMX file, could anyone help with how to fix the error?

    <?xml version="1.0" encoding="utf-8"?>
    <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
      <!-- EF Runtime content -->
      <edmx:Runtime>
        <!-- SSDL content -->
        <edmx:StorageModels>
          <Schema Namespace="DynamicEntitiesModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
            <EntityContainer Name="DynamicEntitiesModelStoreContainer">
              <EntitySet Name="vwParentObject" store:Type="Views" Schema="DynamicDataTest" EntityType="DynamicEntitiesModel.Store.vwParentObject" />
              <EntitySet Name="vwChildObject" store:Type="Views" Schema="DynamicDataTest" EntityType="DynamicEntitiesModel.Store.vwChildObject" />
              <EntitySet Name="vwParentObject_ChildObject" store:Type="Views" Schema="DynamicDataTest" EntityType="DynamicEntitiesModel.Store.vwParentObject_ChildObject" />
              <AssociationSet Name="FK_ParentObject_ChildObject" Association="DynamicEntitiesModel.Store.FK_ParentObject_ChildObject">
                <End Role="vwParentObject" EntitySet="vwParentObject" />
                <End Role="vwParentObject_ChildObject" EntitySet="vwParentObject_ChildObject" />
              </AssociationSet>
              <AssociationSet Name="FK_ChildObject_ParentObject" Association="DynamicEntitiesModel.Store.FK_ChildObject_ParentObject">
                <End Role="vwChildObject" EntitySet="vwChildObject" />
                <End Role="vwParentObject_ChildObject" EntitySet="vwParentObject_ChildObject" />
              </AssociationSet>
            </EntityContainer>
            <EntityType Name="vwParentObject">
              <Key>
                <PropertyRef Name="ParentObjectID" />
              </Key>
              <Property Name="ParentObjectID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
              <Property Name="CreatedBy" Type="nvarchar" MaxLength="500" Nullable="false" />
              <Property Name="CreatedDate" Type="datetime" Nullable="false" />
              <Property Name="ModifiedBy" Type="nvarchar" MaxLength="500" Nullable="true" />
              <Property Name="ModifiedDate" Type="datetime" Nullable="true" />
              <Property Name="Timestamp" Type="timestamp" Nullable="false" />
              <Property Name="Title" Type="nvarchar" Nullable="false" MaxLength="100" />
              <Property Name="DateTimeValue" Type="datetime" Nullable="false" />
            </EntityType>
            <EntityType Name="vwChildObject">
              <Key>
                <PropertyRef Name="ChildObjectID" />
              </Key>
              <Property Name="ChildObjectID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
              <Property Name="CreatedBy" Type="nvarchar" MaxLength="500" Nullable="false" />
              <Property Name="CreatedDate" Type="datetime" Nullable="false" />
              <Property Name="ModifiedBy" Type="nvarchar" MaxLength="500" Nullable="true" />
              <Property Name="ModifiedDate" Type="datetime" Nullable="true" />
              <Property Name="Timestamp" Type="timestamp" Nullable="false" />
              <Property Name="ColumnName" Type="nvarchar" Nullable="true" MaxLength="100" />
            </EntityType>
            <EntityType Name="vwParentObject_ChildObject">
              <Key>
                <PropertyRef Name="ParentObjectID" />
                <PropertyRef Name="ChildObjectID" />
              </Key>
              <Property Name="ParentObjectID" Type="int" Nullable="false" />
              <Property Name="ChildObjectID" Type="int" Nullable="false" />
            </EntityType>
            <Association Name="FK_ParentObject_ChildObject">
              <End Role="vwParentObject" Type="DynamicEntitiesModel.Store.vwParentObject" Multiplicity="1" />
              <End Role="vwParentObject_ChildObject" Type="DynamicEntitiesModel.Store.vwParentObject_ChildObject" Multiplicity="*" />
              <ReferentialConstraint>
                <Principal Role="vwParentObject">
                  <PropertyRef Name="ParentObjectID" />
                </Principal>
                <Dependent Role="vwParentObject_ChildObject">
                  <PropertyRef Name="ChildObjectID" />
                </Dependent>
              </ReferentialConstraint>
            </Association>
            <Association Name="FK_ChildObject_ParentObject">
              <End Role="vwChildObject" Type="DynamicEntitiesModel.Store.vwChildObject" Multiplicity="1" />
              <End Role="vwParentObject_ChildObject" Type="DynamicEntitiesModel.Store.vwParentObject_ChildObject" Multiplicity="*" />
              <ReferentialConstraint>
                <Principal Role="vwChildObject">
                  <PropertyRef Name="ChildObjectID" />
                </Principal>
                <Dependent Role="vwParentObject_ChildObject">
                  <PropertyRef Name="ChildObjectID" />
                </Dependent>
              </ReferentialConstraint>
            </Association>
          </Schema>
        </edmx:StorageModels>
        <!-- CSDL content -->
        <edmx:ConceptualModels>
          <Schema Namespace="DynamicEntitiesModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
            <EntityContainer Name="DynamicEntities">
              <EntitySet Name="ParentObject" EntityType="DynamicEntitiesModel.ParentObject" />
              <EntitySet Name="ChildObject" EntityType="DynamicEntitiesModel.ChildObject" />
              <AssociationSet Name="ParentObject_ChildObject" Association="DynamicEntitiesModel.ParentObject_ChildObject">
                <End Role="ParentObject" EntitySet="ParentObject" />
                <End Role="ChildObject" EntitySet="ChildObject" />
              </AssociationSet>
            </EntityContainer>
            <EntityType Name="ParentObject">
              <Key>
                <PropertyRef Name="ParentObjectID" />
              </Key>
              <Property Name="ParentObjectID" Type="Int32" Nullable="false" />
              <Property Name="CreatedBy" Type="String" MaxLength="500" Nullable="false" />
              <Property Name="CreatedDate" Type="DateTime" Nullable="false" />
              <Property Name="ModifiedBy" Type="String" MaxLength="500" Nullable="true" />
              <Property Name="ModifiedDate" Type="DateTime" Nullable="true" />
              <Property Name="Timestamp" Type="Binary" Nullable="false" />
              <Property Name="Title" Type="String" Nullable="false" MaxLength="100" />
              <Property Name="DateTimeValue" Type="DateTime" Nullable="false" />
              <NavigationProperty Name="ChildObject" Relationship="DynamicEntitiesModel.ParentObject_ChildObject" FromRole="ParentObject" ToRole="ChildObject" />
            </EntityType>
            <EntityType Name="ChildObject">
              <Key>
                <PropertyRef Name="ChildObjectID" />
              </Key>
              <Property Name="ChildObjectID" Type="Int32" Nullable="false" />
              <Property Name="CreatedBy" Type="String" MaxLength="500" Nullable="false" />
              <Property Name="CreatedDate" Type="DateTime" Nullable="false" />
              <Property Name="ModifiedBy" Type="String" MaxLength="500" Nullable="true" />
              <Property Name="ModifiedDate" Type="DateTime" Nullable="true" />
              <Property Name="Timestamp" Type="Binary" Nullable="false" />
              <Property Name="ColumnName" Type="String" Nullable="true" MaxLength="100" />
              <NavigationProperty Name="ParentObject" Relationship="DynamicEntitiesModel.ParentObject_ChildObject" FromRole="ChildObject" ToRole="ParentObject" />
            </EntityType>
            <Association Name="ParentObject_ChildObject">
              <End Type="DynamicEntitiesModel.ParentObject" Role="ParentObject" Multiplicity="*" />
              <End Type="DynamicEntitiesModel.ChildObject" Role="ChildObject" Multiplicity="*" />
            </Association>
          </Schema>
        </edmx:ConceptualModels>
        <!-- C-S mapping content -->
        <edmx:Mappings>
          <Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
            <EntityContainerMapping StorageEntityContainer="DynamicEntitiesModelStoreContainer" CdmEntityContainer="DynamicEntities">
              <EntitySetMapping Name="ParentObject">
                <EntityTypeMapping TypeName="IsTypeOf(DynamicEntitiesModel.ParentObject)">
                  <MappingFragment StoreEntitySet="vwParentObject">
                    <ScalarProperty Name="ParentObjectID" ColumnName="ParentObjectID" />
                    <ScalarProperty Name="CreatedBy" ColumnName="CreatedBy" />
                    <ScalarProperty Name="CreatedDate" ColumnName="CreatedDate" />
                    <ScalarProperty Name="ModifiedBy" ColumnName="ModifiedBy" />
                    <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
                    <ScalarProperty Name="Timestamp" ColumnName="Timestamp" />
                    <ScalarProperty Name="Title" ColumnName="Title" />
                    <ScalarProperty Name="DateTimeValue" ColumnName="DateTimeValue" />
                  </MappingFragment>
                </EntityTypeMapping>
              </EntitySetMapping>
              <EntitySetMapping Name="ChildObject">
                <EntityTypeMapping TypeName="IsTypeOf(DynamicEntitiesModel.ChildObject)">
                  <MappingFragment StoreEntitySet="vwChildObject">
                    <ScalarProperty Name="ChildObjectID" ColumnName="ChildObjectID" />
                    <ScalarProperty Name="CreatedBy" ColumnName="CreatedBy" />
                    <ScalarProperty Name="CreatedDate" ColumnName="CreatedDate" />
                    <ScalarProperty Name="ModifiedBy" ColumnName="ModifiedBy" />
                    <ScalarProperty Name="ModifiedDate" ColumnName="ModifiedDate" />
                    <ScalarProperty Name="Timestamp" ColumnName="Timestamp" />
                    <ScalarProperty Name="ColumnName" ColumnName="ColumnName" />
                  </MappingFragment>
                </EntityTypeMapping>
              </EntitySetMapping>
              <AssociationSetMapping Name="ParentObject_ChildObject" TypeName="DynamicEntitiesModel.ParentObject_ChildObject" StoreEntitySet="ParentObject_ChildObject">
                <EndProperty Name="ParentObject">
                  <ScalarProperty Name="ParentObjectID" ColumnName="ParentObjectID" />
                </EndProperty>
                <EndProperty Name="ChildObject">
                  <ScalarProperty Name="ChildObjectID" ColumnName="ChildObjectID" />
                </EndProperty>
              </AssociationSetMapping>
            </EntityContainerMapping>
          </Mapping>
        </edmx:Mappings>
      </edmx:Runtime>
      <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
      <Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx">
        <Connection>
          <DesignerInfoPropertySet>
            <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
          </DesignerInfoPropertySet>
        </Connection>
        <Options>
          <DesignerInfoPropertySet>
            <DesignerProperty Name="ValidateOnBuild" Value="true" />
          </DesignerInfoPropertySet>
        </Options>
        <!-- Diagram content (shape and connector positions) -->
        <Diagrams>
          <Diagram Name="DynamicEntities">
            <EntityTypeShape EntityType="DynamicEntitiesModel.Entity" Width="1.5" PointX="0.75" PointY="0.75" Height="1.2636116536458335" IsExpanded="true" />
            <EntityTypeShape EntityType="DynamicEntitiesModel.Incident" Width="1.5" PointX="2.75" PointY="0.75" Height="1.427958984375" IsExpanded="true" />
            <EntityTypeShape EntityType="DynamicEntitiesModel.PaulsTestEntity" Width="1.5" PointX="0.75" PointY="3.75" Height="1.4279589843749996" IsExpanded="true" />
            <EntityTypeShape EntityType="DynamicEntitiesModel.Person" Width="1.5" PointX="2.75" PointY="3.75" Height="1.4279589843749996" IsExpanded="true" />
            <EntityTypeShape EntityType="DynamicEntitiesModel.EntityName" Width="1.5" PointX="6.25" PointY="1" Height="1.4279589843749998" />
          </Diagram>
        </Diagrams>
      </Designer>
    </edmx:Edmx>

    Thanks,
    Monday, March 23, 2009 9:34 AM

Answers

  • Change line 62 to reference the ParentObjectID instead of the ChildObjectID like this:

    <Association Name="FK_ParentObject_ChildObject">
      <
    End Role="vwParentObject" Type="DynamicEntitiesModel.Store.vwParentObject" Multiplicity="1" />
      <
    End Role="vwParentObject_ChildObject" Type="DynamicEntitiesModel.Store.vwParentObject_ChildObject" Multiplicity="*" />
      <
    ReferentialConstraint>
        <
    Principal Role="vwParentObject">
            <
    PropertyRef Name="ParentObjectID" />
        </
    Principal>
        <
    Dependent Role="vwParentObject_ChildObject">
          <
    PropertyRef Name="ParentObjectID" /> <!-- used to have childObjectID here -->
        </
    Dependent>
      </
    ReferentialConstraint>
    </
    Association>

    Friday, March 27, 2009 3:18 PM

All replies

  • It appears that in this line

    <AssociationSetMapping Name="ParentObject_ChildObject" TypeName="DynamicEntitiesModel.ParentObject_ChildObject" StoreEntitySet="ParentObject_ChildObject">

    StoreEntitySet is referencing a Store EntitySet that doesn't exist; it looks like it should probably be (see highlighted part)

    <AssociationSetMapping Name="ParentObject_ChildObject" TypeName="DynamicEntitiesModel.ParentObject_ChildObject" StoreEntitySet="vwParentObject_ChildObject">

    Thanks,
    jeff
    Monday, March 23, 2009 2:49 PM
  • Thanks Jeff,

    I changed that but I now get:

    Problem in Mapping Fragment starting at line 199: Foreign key constraint 'FK_ParentObject_ChildObject' from table vwParentObject_ChildObject (ChildObjectID) to table vwParentObject (ParentObjectID): The columns of table vwParentObject_ChildObject are mapped to AssociationSet ParentObject_ChildObject's End ChildObject but the key columns of table vwParentObject are not mapped to the keys of the EntitySet ChildObject corresponding to this End.

    Have had a look at the file but can't see what its getting at?

    Thanks!
    Tuesday, March 24, 2009 9:47 AM
  • Change line 62 to reference the ParentObjectID instead of the ChildObjectID like this:

    <Association Name="FK_ParentObject_ChildObject">
      <
    End Role="vwParentObject" Type="DynamicEntitiesModel.Store.vwParentObject" Multiplicity="1" />
      <
    End Role="vwParentObject_ChildObject" Type="DynamicEntitiesModel.Store.vwParentObject_ChildObject" Multiplicity="*" />
      <
    ReferentialConstraint>
        <
    Principal Role="vwParentObject">
            <
    PropertyRef Name="ParentObjectID" />
        </
    Principal>
        <
    Dependent Role="vwParentObject_ChildObject">
          <
    PropertyRef Name="ParentObjectID" /> <!-- used to have childObjectID here -->
        </
    Dependent>
      </
    ReferentialConstraint>
    </
    Association>

    Friday, March 27, 2009 3:18 PM