Page 1 of 1

AssociationSetMapping for Composite PK - Foreign Key

Posted: Tue 28 Sep 2010 16:15
by jacksparrow
Hello,

We are using dotconnect for Oracle v5.70.152 for generating Entity Framework.

We have a Product table with sku as PK and ProductDescription table with sku, languageId as composite PK. The sku in ProductDescription table is a FK to the (PK) sku column in Product table. When we generate the EF, the sku FK relationship is not mapped. If the FK is not part of a PK, the relationship is generated correctly.

Please let us know if this is a bug in the Devart EF.

Thanks.

Posted: Wed 29 Sep 2010 09:33
by AndreyR
The problem is associated with the fact that you have a single-column entity key on one side of association, and a multi-column key on the other side.
There is no support for such association scenario in Entity Framework. There should be either association between two entity keys, or one of the association ends should not be a part of Entity Key.

Posted: Mon 11 Oct 2010 15:56
by jacksparrow
I am able to create the association manually in the Designer as follows (in the .edml file).

Code: Select all

 
            
            
          

Code: Select all

 
            
              
            
            
              
              
            
          
The generated x.Designer.cs file also includes the below navigation properties for the Productdescription class.

Code: Select all

#region Navigation Properties

        /// 
        /// There are no comments for Product in the schema.
        /// 
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("x", "Product_Productdescription", "Product")]
        public Product Product
        {
            get
            {
                return ((IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference("x.Product_Productdescription", "Product").Value;
            }
            set
            {
                ((IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference("x.Product_Productdescription", "Product").Value = value;
            }
        }

        /// 
        /// There are no comments for Product in the schema.
        /// 
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference ProductReference
        {
            get
            {
                return ((IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference("x.Product_Productdescription", "Product");
            }
            set
            {
                if (value != null)
                {
                    ((IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference("x.Product_Productdescription", "Product", value);
                }
                else 
                {
                    ((IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference("x.Product_Productdescription", "Product").Value = null;
                }
            }
        }

        #endregion
Please let us know if it is a limitation of the Devart Entity designer to generate the AssociationSet automatically.

Posted: Tue 12 Oct 2010 10:05
by AndreyR
Could you please post here or send us (support * devart * com, subject "EF: Association not added to model") the script of the tables and the foreign key?
We are working on associations in the upcoming Beta build of Entity Developer 3.0, this will help us in testing.

Posted: Tue 23 Nov 2010 16:45
by jacksparrow
I have sent the table creation scripts. Please keep us posted on your findings.

Posted: Wed 24 Nov 2010 13:06
by AndreyR
We have fixed the error in the 5.70.180 build of dotConnect for Oracle.
I have made a test and the association was generated successfully.