The number of ThisKey columns is different from the number of OtherKey columns for the association property

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
dqrest
Posts: 21
Joined: Tue 15 Sep 2015 06:01

The number of ThisKey columns is different from the number of OtherKey columns for the association property

Post by dqrest » Fri 09 Oct 2020 11:37

I have the following mapped classes in C#:

Code: Select all

namespace TypeTreeMapping.BaseClasses.Kernel.T1
{
    [Table(Name = "XX")]
    public class ObjType
    {
        long _No;
        [Column(Name = "NO", Storage = "_No", IsPrimaryKey = true)]
        public long No { get { return _No; } }

        string _Rowid;
        [Column(Name = "ROWID", Storage = "_Rowid", IsPrimaryKey = true)]
        public string Rowid { get { return _Rowid; } }

    }
    [Table(Name = "YY")]
    public class ObjTypeState
    {
        long _No;
        [Column(Name = "NO", Storage = "_No", IsPrimaryKey = true)]
        public long No { get { return _No; } }

        string _Rowid;
        [Column(Name = "ROWID", Storage = "_Rowid", IsPrimaryKey = true)]
        public string Rowid { get { return _Rowid; } }

        long? _ObjTypeNo;
        [Column(Name = "OBJ$TYPE_NO", Storage = "_ObjTypeNo")]
        public long? ObjTypeNo { get { return _ObjTypeNo; } }
    }
}


Code: Select all

namespace Mappings.Kernel.T1
{    
    [Table(Name = "XX")]
    public class ObjType1 : TypeTreeMapping.BaseClasses.Kernel.T1.ObjType
    {
        EntitySet<Mappings.Kernel.T1.ObjTypeState> _ES_ObjTypeStates = new EntitySet<Mappings.Kernel.T1.ObjTypeState>();
        [Association(OtherKey = "ObjTypeNo", Storage = "_ES_ObjTypeStates")]
        public EntitySet<Mappings.Kernel.T1.ObjTypeState> ES_ObjTypeStates { get { return _ES_ObjTypeStates; } }
    }
    
    [Table(Name = "YY")]
    public class ObjTypeState1: TypeTreeMapping.BaseClasses.Kernel.T1.ObjTypeState
    {
        EntityRef<Mappings.Kernel.T1.ObjType> _ER_ObjTypeNo;
        [Association(ThisKey = "ObjTypeNo", Storage = "_ER_ObjTypeNo")]
        public Mappings.Kernel.T1.ObjType E_ObjTypeNo { get { return _ER_ObjTypeNo.Entity; } }
    }
}

Code: Select all

[ProviderAttribute(typeof(Devart.Data.Oracle.Linq.Provider.OracleDataProvider))]
    public class TypeTreeDataContext : DataContext
    {
        public TypeTreeDataContext(OracleConnection conn) : base(conn) { ObjectTrackingEnabled = false; }
        
        public Table<Mappings.Kernel.T1.ObjType1> ObjTypes1;        
        public Table<Mappings.Kernel.T1.ObjTypeState1> ObjTypeStates1;
    }

Now I try to migrate from dotConnect for Oracle 6.60.258 to dotConnect for Oracle 9.13.1098 (trial) in the web-projects.
In 6.60.258 there is possible to use nullable primary keys, but I can not do it in 9.13.1098. That's why to save nullable fields in the mapped classes I use the rowid as a new primary key.

In the example I remove the nullable primary key attribute from the field "ObjTypeNo" of the class "ObjTypeState" and add the rowid field to "ObjTypeState", "ObjType" classes. After running I have the error "The number of ThisKey columns is different from the number of OtherKey columns for the association property 'ES_ObjTypeStates' in the type 'ObjType'".
How to solve this problem?

Shalex
Site Admin
Posts: 9077
Joined: Thu 14 Aug 2008 12:44

Re: The number of ThisKey columns is different from the number of OtherKey columns for the association property

Post by Shalex » Sat 17 Oct 2020 15:22

You should specify the ThisKey and OtherKey attributes explicitly in all associations. Refer to https://www.devart.com/linqconnect/docs ... pping.html.

Post Reply