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

Changing the default collection type for the navigation properties causes an exception

4 Answers 68 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yassine
Top achievements
Rank 1
Yassine asked on 01 Dec 2014, 04:57 PM
Hello everyone, first, thanks for this awesome ORM.
i'm having a hard time changing the default collection type for the navigation properties in a one-to-many or many-to-many association.
i found this part in the docs
http://docs.telerik.com/data-access/developers-guide/code-generation/customizing-code-generation/domain-model/data-access-tasks-customise-code-generation-collection-generation
but, when i apply the mentioned changes, i get the exception
****
An exception of type 'Telerik.OpenAccess.Exceptions.DataStoreException' occurred in Telerik.OpenAccess.dll but was not handled in user code

Additional information: Link table batch insert failed: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Categorie_Cheque'. ---> System.Data.SqlClient.SqlException: Invalid object name 'Categorie_Cheque'.

   at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)

   at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)

   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)

   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)

   at OpenAccessRuntime.Intellitrace.Update(String id, DbDataAdapter adapter, DataRow[] rows)

   at Telerik.OpenAccess.RT.sql.Batch.Perform(String connId, DbDataAdapter adapter, DataRow[] rows)

   at Telerik.OpenAccess.Runtime.Logging.LoggingDbCommand.ExecuteBatch(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.CommandImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   --- End of inner exception stack trace ---

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at OpenAccessRuntime.Relational.conn.LoggingStatement.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at Telerik.OpenAccess.RT.sql.Batch.ExecuteBatchDataTable(Boolean withInfo)

Field: Telerik.OpenAccess.TrackedBindingList`1[[Taxwise.Cheques.Cheque, Taxwise.Cheques, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] Taxwise.Cheques.Categorie._cheques

INSERT INTO [Categorie_Cheque]([Id], [seq], [Id2]) VALUES (@p0, @p1, @p2)

Batch Entry 0 (set event logging to all to see parameter data) Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Categorie_Cheque'. ---> System.Data.SqlClient.SqlException: Invalid object name 'Categorie_Cheque'.

   at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)

   at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)

   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)

   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)

   at OpenAccessRuntime.Intellitrace.Update(String id, DbDataAdapter adapter, DataRow[] rows)

   at Telerik.OpenAccess.RT.sql.Batch.Perform(String connId, DbDataAdapter adapter, DataRow[] rows)

   at Telerik.OpenAccess.Runtime.Logging.LoggingDbCommand.ExecuteBatch(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.CommandImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   --- End of inner exception stack trace ---

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.StatementImp.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at OpenAccessRuntime.Relational.conn.LoggingStatement.Execute(DbDataAdapter adapter, DataRow[] rows, Batch batch)

   at Telerik.OpenAccess.RT.sql.Batch.ExecuteBatchDataTable(Boolean withInfo)

4 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 02 Dec 2014, 11:12 AM
Hello Yassine,

I think you changed from foreign key collection to a join table collection. In order to make the transition complete, you will need to allow DataAccess to update the database schema, otherwise the join table will not be created and an exception like the one you've got will be thrown. 
In order to do that you will need to control the 'Update Schema' property of the referencing class, set it to true and perform the 'Update Database from Model...' operation on the .rlinq designer.

Regards,
Thomas
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Yassine
Top achievements
Rank 1
answered on 02 Dec 2014, 03:13 PM
thank you for your answer and your time, can you elaborate on the "Update scheme" part, with an example if possible, i'm fairly new to Telerik dataAccess. 
Thanks again.
0
Yassine
Top achievements
Rank 1
answered on 02 Dec 2014, 03:38 PM
it's ok, i found it, and it's working flawlessly, thanks Sir.
0
Kaloyan Nikolov
Telerik team
answered on 05 Dec 2014, 09:48 AM
Hi Yassine,

we are happy you have resolved the issue. 

Should you have any further questions do not hesitate to get back to us. 

Regards,
Kaloyan Nikolov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Development (API, general questions)
Asked by
Yassine
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Yassine
Top achievements
Rank 1
Kaloyan Nikolov
Telerik team
Share this question
or