Zeid


I'm using Orcas beta 2 and I'm trying to create an association between two tables, Nodes and Interfaces. I used the VS to create the initial edm for me, but when I try to create the assocation and build the project I get an error

"No mapping specified for the following entity sets/association sets - NodesInterfaces"

I tried to create the mapping by hand, but I get the error

"A condition cannot be bound to a property and a column at the same time."


My Assocation was defined as

<Association Name="NodesInterfaces" >
<End Type="Model.Nodes" Role="Nodes" Multiplicity="1" />
<End Type="Model.Interfaces" Role="Interfaces" Multiplicity="*" />
</Association>

<AssociationSetMapping Name="NodesInterfaces" TypeName="Model.NodesInterfaces" StoreEntitySet="Interfaces">
<EndProperty Name="Interfaces">
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
</EndProperty>

<EndProperty Name="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
</AssociationSetMapping>


Re: ADO.NET (Pre-release) Problem with Associations

Michael Pizzo - MSFT

The error you are getting generally implies a "Condition" element which doesn't appear in the attached snippet. I have had cases where my edits to the model didn't necessarily get picked up unless I cleaned and did a full rebuild of the project, so you might try that and see if it solves the problem, otherwise could you send the complete mapping specification






Re: ADO.NET (Pre-release) Problem with Associations

derhally

Here is my mapping. I actually went and cleaned my project and rebuilt and I get the error:

The Column 'InterfaceID' specified as part of this MSL does not exist in Metadata workspace. line 111

Code Block


< xml version="1.0" encoding="utf-8" >
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:Designer>
<edmx:Connection />
<edmx:Options />
<edmx:ReverseEngineer />
<edmx:Diagrams />
</edmx:Designer>
<edmx:Runtime>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="Model" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="Orion2">
<EntitySet Name="Interfaces" EntityType="Model.Interfaces" />
<EntitySet Name="Nodes" EntityType="Model.Nodes" />
<AssociationSet Name="NodesInterfaces" Association="Model.NodesInterfaces" >
<End Role="Nodes" EntitySet="Nodes" />
<End Role="Interfaces" EntitySet="Interfaces" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Interfaces">
<Key>
<PropertyRef Name="NodeID" />
<PropertyRef Name="InterfaceID" />
</Key>
<Property Name="NodeID" Type="Int32" Nullable="false" />
<Property Name="InterfaceID" Type="Int32" Nullable="false" />

<Property Name="InterfaceName" Type="String" MaxLength="255" Unicode="false" />
<Property Name="InterfaceIndex" Type="Int32" />

<Property Name="Caption" Type="String" MaxLength="255" Unicode="false" />
<NavigationProperty Name="Node" Relationship="Model.NodesInterfaces" FromRole="Interfaces" ToRole="Nodes" />
</EntityType>
<EntityType Name="Nodes">
<Key>
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="Int32" Nullable="false" />
<Property Name="Caption" Type="String" MaxLength="255" Unicode="false" />
<Property Name="Vendor" Type="String" MaxLength="255" Unicode="false" />
<Property Name="Location" Type="String" MaxLength="255" Unicode="false" />
<NavigationProperty Name="Interfaces" Relationship="Model.NodesInterfaces" FromRole="Nodes" ToRole="Interfaces" />
</EntityType>
<Association Name="NodesInterfaces" >
<End Type="Model.Nodes" Role="Nodes" Multiplicity="1" />
<End Type="Model.Interfaces" Role="Interfaces" Multiplicity="*" />
</Association>
</Schema>
</edmx:ConceptualModels>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="Model.Store" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
<EntityContainer Name="dbo">
<EntitySet Name="Interfaces" EntityType="Model.Store.Interfaces" />
<EntitySet Name="Nodes" EntityType="Model.Store.Nodes" />
</EntityContainer>
<EntityType Name="Interfaces">
<Key>
<PropertyRef Name="InterfaceID" />
</Key>
<Property Name="NodeID" Type="int" Nullable="false" />
<Property Name="InterfaceID" Type="int" Nullable="false" StoreGeneratedPattern="identity" />
<Property Name="ObjectSubType" Type="varchar" MaxLength="50" />
<Property Name="InterfaceName" Type="varchar" MaxLength="255" />
<Property Name="InterfaceIndex" Type="int" />
<Property Name="InterfaceType" Type="int" />
<Property Name="Caption" Type="varchar" MaxLength="255" />
</EntityType>
<EntityType Name="Nodes">
<Key>
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="int" Nullable="false" StoreGeneratedPattern="identity" />
<Property Name="Caption" Type="varchar" MaxLength="255" />
<Property Name="Vendor" Type="varchar" MaxLength="255" />
<Property Name="Location" Type="varchar" MaxLength="255" />
</EntityType>
</Schema>
</edmx:StorageModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS">
<EntityContainerMapping StorageEntityContainer="dbo" CdmEntityContainer="Orion2">
<EntitySetMapping Name="Interfaces">
<EntityTypeMapping TypeName="IsTypeOf(Model.Interfaces)">
<MappingFragment StoreEntitySet="Interfaces">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
<ScalarProperty Name="InterfaceName" ColumnName="InterfaceName" />
<ScalarProperty Name="InterfaceIndex" ColumnName="InterfaceIndex" />
<ScalarProperty Name="Caption" ColumnName="Caption" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Nodes">
<EntityTypeMapping TypeName="IsTypeOf(Model.Nodes)">
<MappingFragment StoreEntitySet="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
<ScalarProperty Name="Caption" ColumnName="Caption" />
<ScalarProperty Name="Vendor" ColumnName="Vendor" />
<ScalarProperty Name="Location" ColumnName="Location" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="NodesInterfaces" TypeName="Model.NodesInterfaces" StoreEntitySet="Nodes">
<EndProperty Name="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
<EndProperty Name="Interfaces">
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
</EndProperty>
</AssociationSetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
</edmx:Edmx>





Re: ADO.NET (Pre-release) Problem with Associations

Srikanth Mandadi - MSFT

The error pointed to the correct line number.

The problem is with this AssociationSetMapping( see the bold part),

<AssociationSetMapping Name="NodesInterfaces" TypeName="Model.NodesInterfaces" StoreEntitySet="Nodes">
<EndProperty Name="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
<EndProperty Name="Interfaces">
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
</EndProperty>
</AssociationSetMapping>

You have to map AssociationSet to the table that has the foreign key. You are mapping the association set to the "Nodes" Table here. But Nodes table does not contain the foreign key. It is the Interfaces table that has the foreign key.

So try this instead.

<AssociationSetMapping Name="NodesInterfaces" TypeName="Model.NodesInterfaces" StoreEntitySet="Interfaces">
<EndProperty Name="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
<EndProperty Name="Interfaces">
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
</EndProperty>
</AssociationSetMapping>

You would also need a referential constraint in the Conceptual Model since NodeID column in Interfaces table is both acting as a PrimaryKey and ForeignKey. So change your AssociationType for NodesInterfaces at line 45 to the below:

<Association Name="NodesInterfaces" >
<End Type="Model.Nodes" Role="Nodes" Multiplicity="1" />
<End Type="Model.Interfaces" Role="Interfaces" Multiplicity="*" />

<ReferentialConstraint>
<Principal Role="Nodes">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Interfaces">
<PropertyRef Name="NodeID" />
</Dependent>
</ReferentialConstraint>
</Association>

I did not have time to actually try it out. Let me know if it does not work.

Thanks

Srikanth






Re: ADO.NET (Pre-release) Problem with Associations

derhally

Seems like the EDM editor had some issues when it was generating the ReferentialConstraint. This is probably because it never asked me which keys I wanted to use for the association.

Ok, now I understand your changes and they make sense, but after updating the mappings with your fixes I'm getting an error stating

Error 12 Problem in Mapping Fragment(s) starting at line(s) (113): Must specify mapping for all key properties (NodeID, InterfaceID) of end Interfaces in relationship NodesInterfaces. Line 114






Re: ADO.NET (Pre-release) Problem with Associations

Srikanth Mandadi - MSFT

My bad. I made a mistake in the AssociationSetMapping for NodesInterfaces. All the key properties of each end need to be mapped. Here is a corrected one:

<AssociationSetMapping Name="NodesInterfaces" TypeName="Model.NodesInterfaces" StoreEntitySet="Interfaces">
<EndProperty Name="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
<EndProperty Name="Interfaces">
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
</AssociationSetMapping>

But even after this correction, there is one more problem in this mapping. Our Mapping infrastructure requires that the Key properties in Conceptual Space be mapped to Key properties of Storage Space. The "Interfaces" Entity Type is violating this requirement since in the Conceptual space both InterfaceID and NodeID are Key properties but on the Store side only InterfaceID is the Key property. There are two ways to fix this proplem.

  1. One way to fix this problem is to make NodeID column part of the key on Interfaces column.
  2. The second way is to drop the NodeID property from the list of "Interfaces" Entity Type properties and just map NodeId column on "Interfaces" table to "NodesInterfaces" Association. You will still have the Navigation property in the conceptual space that will let you access the associated Node from the Interfaces type.

I have pasted a Edmx file based on the approach mentioned in 1( make NodeID column part of the key on Interfaces table).

< xml version="1.0" encoding="utf-8" >
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmxBig Smileesigner>
<edmx:Connection />
<edmxSurpriseptions />
<edmx:ReverseEngineer />
<edmxBig Smileiagrams />
</edmxBig Smileesigner>
<edmx:Runtime>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="Model" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<EntityContainer Name="Orion2">
<EntitySet Name="Interfaces" EntityType="Model.Interfaces" />
<EntitySet Name="Nodes" EntityType="Model.Nodes" />
<AssociationSet Name="NodesInterfaces" Association="Model.NodesInterfaces" >
<End Role="Nodes" EntitySet="Nodes" />
<End Role="Interfaces" EntitySet="Interfaces" />
</AssociationSet>
</EntityContainer>
<EntityType Name="Interfaces">
<Key>
<PropertyRef Name="NodeID" />
<PropertyRef Name="InterfaceID" />
</Key>
<Property Name="NodeID" Type="Int32" Nullable="false" />
<Property Name="InterfaceID" Type="Int32" Nullable="false" />

<Property Name="InterfaceName" Type="String" MaxLength="255" Unicode="false" />
<Property Name="InterfaceIndex" Type="Int32" />

<Property Name="Caption" Type="String" MaxLength="255" Unicode="false" />
<NavigationProperty Name="Node" Relationship="Model.NodesInterfaces" FromRole="Interfaces" ToRole="Nodes" />
</EntityType>
<EntityType Name="Nodes">
<Key>
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="Int32" Nullable="false" />
<Property Name="Caption" Type="String" MaxLength="255" Unicode="false" />
<Property Name="Vendor" Type="String" MaxLength="255" Unicode="false" />
<Property Name="Location" Type="String" MaxLength="255" Unicode="false" />
<NavigationProperty Name="Interfaces" Relationship="Model.NodesInterfaces" FromRole="Nodes" ToRole="Interfaces" />
</EntityType>
<Association Name="NodesInterfaces" >
<End Type="Model.Nodes" Role="Nodes" Multiplicity="1" />
<End Type="Model.Interfaces" Role="Interfaces" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Nodes">
<PropertyRef Name="NodeID" />
</Principal>
<Dependent Role="Interfaces">
<PropertyRef Name="NodeID" />
</Dependent>
</ReferentialConstraint>

</Association>
</Schema>
</edmx:ConceptualModels>
<!-- SSDL content -->
<edmxTongue TiedtorageModels>
<Schema Namespace="Model.Store" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl" >
<EntityContainer Name="dbo">
<EntitySet Name="Interfaces" EntityType="Model.Store.Interfaces" />
<EntitySet Name="Nodes" EntityType="Model.Store.Nodes" />
</EntityContainer>
<EntityType Name="Interfaces">
<Key>
<PropertyRef Name="InterfaceID" />
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="int" Nullable="false" />
<Property Name="InterfaceID" Type="int" Nullable="false" StoreGeneratedPattern="identity" />
<Property Name="ObjectSubType" Type="varchar" MaxLength="50" />
<Property Name="InterfaceName" Type="varchar" MaxLength="255" />
<Property Name="InterfaceIndex" Type="int" />
<Property Name="InterfaceType" Type="int" />
<Property Name="Caption" Type="varchar" MaxLength="255" />
</EntityType>
<EntityType Name="Nodes">
<Key>
<PropertyRef Name="NodeID" />
</Key>
<Property Name="NodeID" Type="int" Nullable="false" StoreGeneratedPattern="identity" />
<Property Name="Caption" Type="varchar" MaxLength="255" />
<Property Name="Vendor" Type="varchar" MaxLength="255" />
<Property Name="Location" Type="varchar" MaxLength="255" />
</EntityType>
</Schema>
</edmxTongue TiedtorageModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="urnTongue Tiedchemas-microsoft-com:windowsTongue Tiedtorage:mapping:CS">
<EntityContainerMapping StorageEntityContainer="dbo" CdmEntityContainer="Orion2">
<EntitySetMapping Name="Interfaces">
<EntityTypeMapping TypeName="IsTypeOf(Model.Interfaces)">
<MappingFragment StoreEntitySet="Interfaces">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
<ScalarProperty Name="InterfaceName" ColumnName="InterfaceName" />
<ScalarProperty Name="InterfaceIndex" ColumnName="InterfaceIndex" />
<ScalarProperty Name="Caption" ColumnName="Caption" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Nodes">
<EntityTypeMapping TypeName="IsTypeOf(Model.Nodes)">
<MappingFragment StoreEntitySet="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
<ScalarProperty Name="Caption" ColumnName="Caption" />
<ScalarProperty Name="Vendor" ColumnName="Vendor" />
<ScalarProperty Name="Location" ColumnName="Location" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<AssociationSetMapping Name="NodesInterfaces" TypeName="Model.NodesInterfaces" StoreEntitySet="Interfaces">
<EndProperty Name="Nodes">
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
<EndProperty Name="Interfaces">
<ScalarProperty Name="InterfaceID" ColumnName="InterfaceID" />
<ScalarProperty Name="NodeID" ColumnName="NodeID" />
</EndProperty>
</AssociationSetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
</edmx:Edmx>






Re: ADO.NET (Pre-release) Problem with Associations

derhally


Thanks for your help. Editing this stuff by hand is tough.




Re: ADO.NET (Pre-release) Problem with Associations

Jxxxxxxxx

Hi Srikanth,

I'm having a similar issue which i'm trying to resolve. The main difference in my case is i'm trying to create 1 to many associations between inherited types (Tabe per Type). So are both your options above accurate if both Nodes inherited from an abstract type called NodesBase and Interfaces from InterfacesBase.

Thanks