AssociationSetMapping for Composite PK - Foreign Key

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
jacksparrow
Posts: 9
Joined: Wed 26 May 2010 02:39

AssociationSetMapping for Composite PK - Foreign Key

Post by jacksparrow » Tue 28 Sep 2010 16:15

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 29 Sep 2010 09:33

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.

jacksparrow
Posts: 9
Joined: Wed 26 May 2010 02:39

Post by jacksparrow » Mon 11 Oct 2010 15:56

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 12 Oct 2010 10:05

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.

jacksparrow
Posts: 9
Joined: Wed 26 May 2010 02:39

Post by jacksparrow » Tue 23 Nov 2010 16:45

I have sent the table creation scripts. Please keep us posted on your findings.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 24 Nov 2010 13:06

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.

Post Reply