This is a migrated thread and some comments may be shown as answers.

After Upgrade: Master shared column/second master field uses this column too

22 Answers 267 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Timothy Fischer
Top achievements
Rank 1
Timothy Fischer asked on 05 Nov 2009, 05:58 PM
After upgrading to the Telerik Q3 release of ORM, our product no longer functions and we get an error similar to:

Field 'county' of class 'Model.Asset' maps to a master shared column 'CountyCode', but a second master field 'fieldname' uses this column too.



We cannot run the application any longer - any ideas why this might be occurring and didn't before?

county column mapping goes to:

County.countyCode --> CountyCode

and fieldname mapping goes to:

fieldname.countyCode  --> CountyCode
fieldname.fieldCode  --> FieldCode

Thanks,

Tim

22 Answers, 1 is accepted

Sort by
0
Denis Vulinovich
Top achievements
Rank 1
answered on 06 Nov 2009, 07:33 AM
I've got the same problem.

I have a base class and a derived class that both have a Location property based on a common _location field. I've done this because the setter needs different behavior in each class. The Location property in the derived class uses the "new" modifier.

The Forward Mapping wizard gives the following error message:

An unexpected error occurred. 
Please contact Telerik support with the following error information: 
 
Target method: Telerik.OpenAccess.Sdk.IDEMetaData.IMdValue GetClassId() 
Error: Object reference not set to an instance of an object 

0
Thomas
Telerik team
answered on 06 Nov 2009, 11:41 AM
Hi Denis,

I think this is something different and I've fixed the display issue. I guess, there is a real meta data exception in the errors list, that you should check.

And I would like to ask you to check if the 'new' keyword shouldn't be actually a 'override'; at least from the short description on the purpose this seems logical to me.

Kind regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Denis Vulinovich
Top achievements
Rank 1
answered on 06 Nov 2009, 06:25 PM
Hi Thomas,

I've tried using "override" in the derived class property and "virtual" in the base class, but I still get the same error.

Denis
0
Brian
Top achievements
Rank 1
answered on 06 Nov 2009, 07:23 PM

 

I'm also working with Tim.  We are still having issues.
From the support ticket :

 

1.First of all: Do you want this column to be shared, is it intentional?

2. When a column sharing is intended: Do you really need to expose the same column two times with two reference fields?

1.  The answer to this is yes.  The county code is a primary key on both reference tables and we can't change this.
2.  No.  We only need to expose the column once.  I changed the countyCode extention to db-ref and received other errors (see below).

I've removed the countyCode and and muniCode fields from the class per Shared Columns .  Here are our mappings.

            <field name="county">

              <extension key="db-column">

                <extension key="db-type" value="VARCHAR" />

                <extension key="db-column-name" value="CountyCode" />

                <extension key="db-length" value="2" />

              </extension>

            </field>

            <field name="municipality">

              <extension key="db-ref" value="countyCode">

                <extension key="db-column">   *Also Tried <extension key="db-ref">

                  <extension key="db-type" value="VARCHAR" />

                  <extension key="db-column-name" value="CountyCode" />

                  <extension key="db-length" value="2" />

                </extension>

              </extension>

              <extension key="db-ref" value="muniCode">

                <extension key="db-column">

                  <extension key="db-type" value="VARCHAR" />

                  <extension key="db-column-name" value="MuniCode" />

                  <extension key="db-length" value="3" />

                </extension>

              </extension>

            </field>

When changing

 

              <extension key="db-ref" value="countyCode">

                <extension key="db-column">  

                  <extension key="db-type" value="VARCHAR" />

                  <extension key="db-column-name" value="CountyCode" />

                  <extension key="db-length" value="2" />

                </extension>

              </extension>

To

              <extension key="db-ref" value="countyCode">

                <extension key="db-ref">

                  <extension key="db-type" value="VARCHAR" />

                  <extension key="db-column-name" value="CountyCode" />

                  <extension key="db-length" value="2" />

                </extension>

              </extension>

Received Error:

Error executing query: Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'CountyCode2'.

SQL Generated  

FROM [Asset_Assets] a

LEFT JOIN [Municipalities] AS g ON (a.[CountyCode2] = g.[CountyCode] and a.[MuniCode] = g.[MuniCode])

We still don't know what to do other than remove the reference to the Municipalities table and do the join in our LINQ queries manually.

0
Denis Vulinovich
Top achievements
Rank 1
answered on 07 Nov 2009, 08:05 PM
Hi Thomas,

To get around the problem with the "master shared column" error after the Q3 upgrade, I've rebuilt the relationships in this project.

But now a managed collection isn't working, even though it worked with Q2. I've described this in a new thread, "Managed collection for overridden property".

Denis
0
Thomas
Telerik team
answered on 09 Nov 2009, 05:09 PM
Hello Brian & Tim,

I understand you issue now: a part of the primary key is the same for some tables, and therefore the fk columns in referencing tables should use just one column, although there are two references... leading to two reference fields sharing the same column... leading now to an exception, where no exception was in the Q2 release. Correct?

The simple fix is not to share the columns in the referencing class. This also makes it more logical, because what should happen when the two references are contradictory in that their shared pk value differs? In the past, the internal processing order of the fields determined the outcome (which might have been the right for you). But I will see that we can implement the necessary synchronization code so that such a scenario is possible.

Best wishes,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 18 Jan 2010, 04:07 PM
Is there a fix\solution for this yet?
0
Thomas
Telerik team
answered on 21 Jan 2010, 08:35 AM
Hello Steve,

this should be fixed in the latest version.

Kind regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 25 Jan 2010, 02:17 PM
I'm still getting the error with the latest internal build

I've got a UserID column in a table which references Aspnet_Users, but I also have a Profile table which stores Extra info (same GUID)...I want this Residents table to contain both the AspNetUser and Profile object so I have access to properties from both places...





Server Error in '/' Application.

Field 'profile' of class 'CPSDAL.ResidentSchedule' is the master of a shared column 'userID', but a second reference field 'user' tries to master this column too.
Columns can only be shared between a simple and a reference field. Usually, the reference field is the master and the simple field is the slave.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.OpenAccess.Exceptions.MetadataException: Field 'profile' of class 'CPSDAL.ResidentSchedule' is the master of a shared column 'userID', but a second reference field 'user' tries to master this column too.
Columns can only be shared between a simple and a reference field. Usually, the reference field is the master and the simple field is the slave.

Source Error:

Line 116:		Database db = Database();
Line 117:
Line 118:		IObjectScope newScope = db.GetObjectScope();
Line 119:		return newScope;
Line 120:	}

Source File: c:\Code\CPSLite\web\CPSLite\App_Code\ObjectScopeProvider1.cs    Line: 118

Stack Trace:

[MetadataException: Field 'profile' of class 'CPSDAL.ResidentSchedule' is the master of a shared column 'userID', but a second reference field 'user' tries to master this column too.
Columns can only be shared between a simple and a reference field. Usually, the reference field is the master and the simple field is the slave.]
   Telerik.OpenAccess.RT.ExceptionWrapper.Throw() +13
   OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createSmfForURL() +678
   OpenAccessRuntime.storagemanager.StorageManagerFactoryBuilder.createStorageManagerFactory() +370
   OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.createStorageManagerFactory() +387
   OpenAccessRuntime.DataObjects.PersistenceManagerFactoryBase.init() +754
   OpenAccessRuntime.DataObjects.PersistenceManagerFactoryImp.init() +61
   OpenAccessRuntime.DataObjects.BootstrapPMF.getPersistenceManagerFactory(IDictionary props) +310
   Telerik.OpenAccess.RT.Helper.getPersistenceManagerFactory(IDictionary props) +952
   Telerik.OpenAccess.RT.DatabaseAdapter.AssertPersistenceManagerFactory(String usr, String password, Boolean open) +1455
   Telerik.OpenAccess.RT.DatabaseAdapter.GetObjectScope(TransactionProvider provider) +38
   Telerik.OpenAccess.Database.GetObjectScope() +26
   ObjectScopeProvider1.GetNewObjectScope() in c:\Code\CPSLite\web\CPSLite\App_Code\ObjectScopeProvider1.cs:118
   ObjectScopeProvider1.GetPerRequestScope(HttpContext context) in c:\Code\CPSLite\web\CPSLite\App_Code\ObjectScopeProvider1.cs:140
   Helper.get_Scope() in c:\Code\CPSLite\web\CPSLite\App_Code\Helper.cs:37
   App_Master_Modal.Page_Unload(Object sender, EventArgs e) in c:\Code\CPSLite\web\CPSLite\App_Master\Modal.master.cs:21
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnUnload(EventArgs e) +11026878
   System.Web.UI.Control.UnloadRecursive(Boolean dispose) +154
   System.Web.UI.Control.UnloadRecursive(Boolean dispose) +307
   System.Web.UI.Page.UnloadRecursive(Boolean dispose) +24
   System.Web.UI.Page.ProcessRequestCleanup() +55
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11041050
   System.Web.UI.Page.ProcessRequest() +91
   System.Web.UI.Page.ProcessRequest(HttpContext context) +240
   ASP.residents_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\4d426c4a\7e11f606\App_Web_ppoamr_w.2.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171


Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

0
Jeremy Mann
Top achievements
Rank 1
answered on 25 Jan 2010, 05:14 PM
Just to add comment,  I'm having this issue today as well and I'm on the latest public release (2009.3.1211).
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 25 Jan 2010, 05:16 PM
I should mention I'm using internal Telerik-OpenAccess-ORM-2009.3.1317.1.zip
0
Thomas
Telerik team
answered on 28 Jan 2010, 06:31 PM
Hello Steve & Jeremy,

you are right, and I apologize for giving you a false hope: Fields cannot be shared yet between >1 reference fields. The reason is, that the synchronization code would be quite complex.
My approach would be to use a second Guid field and perform the necessary synchronization manually; In your case with the ASP user this should not be hard (I guess the id is never changing).

Kind regards,
Thomas
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Devanand Chahal
Top achievements
Rank 2
answered on 04 Feb 2010, 09:46 AM
Hello All,

I had same error but I got the solution to this error .... for tghis u have to map the column in different way...see below the part of app.config file

 

 

<field name="programproject"
<
extension key="db-ref" value="programProjectKey">  

 

 

<

 

extension key="db-column"

 

 

<

 

extension key="db-column-name" value="PROGRAMPROJECTKEY" />

 

 

</

 

extension>

 

 

</

 

extension>
</
field
<
field name="programProjectKey">  

 

 

<

 

extension key="db-column">
<
extension key="db-column-name" value="PROGRAMPROJECTKEY" />

 

</

 

extension>
</
field>

 

 



Regards,
Dev

 

 

 

 

 

 

 

 

 

 

0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 07 Jan 2011, 10:38 PM
Hey guys,

This problem still exists, any plans yet to manage it?

0
Alexander
Telerik team
answered on 11 Jan 2011, 03:56 PM
Hi Steve,

I am afraid that this functionality will not be provided soon. Even if this is possible, it would require major changes in the runtime and considerable time to implement. Unfortunately at the moment our development is focused on tasks with higher priority.

Best wishes,
Alexander
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 11 Jan 2011, 05:10 PM
Can we expect it this year by any chance?
0
Alexander
Telerik team
answered on 13 Jan 2011, 03:36 PM
Hello Steve,

I am not able to give you an exact time-frame but I doubt that this will be implemented for Q3 or earlier this year.

Greetings,
Alexander
the Telerik team
Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
0
aiu
Top achievements
Rank 1
answered on 10 Nov 2011, 11:51 AM
I am using the OpenAccess ORM 2.2011 version and is still facing the same problem.

My current project is to build a viewer on top of a legacy database having a lot of multi column primary keys and same column may be part of several foreign key relations.

Questions:
1. How can I model associations to avoid the observed error in my setting?
2. Is the "mapping solution" explained in a previous posting still applicable using the new API?

Kind regards
Arnvid
0
aiu
Top achievements
Rank 1
answered on 10 Nov 2011, 11:52 AM
I am using the OpenAccess ORM 2.2011 version and is still facing the same problem.

My current project is to build a viewer on top of a legacy database having a lot of multi column primary keys and same column may be part of several foreign key relations.

Questions:
1. How can I model associations to avoid the observed error in my setting?
2. Is the "mapping solution" explained in a previous posting still applicable using the new API?

Kind regards
Arnvid
0
Alexander
Telerik team
answered on 15 Nov 2011, 02:11 PM
Hello Aiu,

Unfortunately this problem has not been solved yet. We have prepared an article with instructions how to avoid this behavior with the current versions - you can find it here
I hope that helps.

Regards,
Alexander
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

0
aiu
Top achievements
Rank 1
answered on 16 Nov 2011, 10:01 AM
To modify database schema is not an option for me.  Can this be fixed by modifying the domain model  only ?  For example will it be possible/help to add another field in the domian model referencing the same database column?  In my case I'm only going to read the database, not update it.  Will it help to modify domain model behavior from readwrite to read?

Kind regards
Arnvid

0
Ivailo
Telerik team
answered on 21 Nov 2011, 10:08 AM
Hello Arnvid,

Unfortunately those options would not solve your issue, this is a limitation of OpenAccess ORM runtime. The only solution is to modify the database schema.

We apologize for the inconvenience caused.

Regards,
Ivailo
the Telerik team

NEW and UPDATED OpenAccess ORM Resources. Check them out!

Tags
General Discussions
Asked by
Timothy Fischer
Top achievements
Rank 1
Answers by
Denis Vulinovich
Top achievements
Rank 1
Thomas
Telerik team
Brian
Top achievements
Rank 1
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Jeremy Mann
Top achievements
Rank 1
Devanand Chahal
Top achievements
Rank 2
Alexander
Telerik team
aiu
Top achievements
Rank 1
Ivailo
Telerik team
Share this question
or