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

Error when Deleting Entity

9 Answers 66 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 14 Dec 2014, 12:16 AM
Hi everyone,
after solving this problem
http://www.telerik.com/forums/changing-the-default-collection-type-for-the-navigation-properties-causes-an-exception
all tables have UpdateScheme set to true
now when i try to delete an entity, i get this exception or similar
(i tried setting the IsDependant in the navigation property properties to true, but no difference)
it's a one to many association
An unhandled exception of type 'Telerik.OpenAccess.Exceptions.DataStoreException' occurred in Telerik.OpenAccess.dll

Additional information: Delete link table rows failed: Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Banque_Compte'.

Statement(s) could not be prepared. ---> System.Data.SqlClient.SqlException: Invalid object name 'Banque_Compte'.

Statement(s) could not be prepared.

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)

   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)

   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()

   at System.Data.SqlClient.SqlDataReader.get_MetaData()

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)

   at OpenAccessRuntime.CommandWrapper.ExecuteReader(CommandBehavior behavior)

   at Telerik.OpenAccess.Runtime.Logging.LoggingDbCommand.ExecuteDbDataReader(CommandBehavior behavior)

   at System.Data.Common.DbCommand.ExecuteReader()

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.CommandImp.ExecuteReader()

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate(Nullable`1 commandTimeout)

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

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate(Nullable`1 commandTimeout)

   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate(Nullable`1 commandTimeout)

   at OpenAccessRuntime.Relational.metadata.RelationalLinkCollectionField.deleteOneByOne(CharBuf s, Connection con, Int32 blockStart, Int32 blockEnd, DeletePacket graph)

Field: Telerik.OpenAccess.TrackedBindingList`1[[ValuePlus.Data.Compte, ValuePlus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] ValuePlus.Data.Banque._comptes

Instance: GenericOID@42bb1bab Banque Id=be5f4f6e-50c9-429a-8b0c-e67b1ff14be3

DELETE FROM Banque_Compte WHERE Id = ?

(set event logging to all to see parameter values) Telerik.OpenAccess.RT.sql.SQLException: Invalid object name 'Banque_Compte'.

Statement(s) could not be prepared. ---> System.Data.SqlClient.SqlException: Invalid object name 'Banque_Compte'.

Statement(s) could not be prepared.

   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)

   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)

   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()

   at System.Data.SqlClient.SqlDataReader.get_MetaData()

   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)

   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)

   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)

   at OpenAccessRuntime.CommandWrapper.ExecuteReader(CommandBehavior behavior)

   at Telerik.OpenAccess.Runtime.Logging.LoggingDbCommand.ExecuteDbDataReader(CommandBehavior behavior)

   at System.Data.Common.DbCommand.ExecuteReader()

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.CommandImp.ExecuteReader()

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate(Nullable`1 commandTimeout)

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

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate(Nullable`1 commandTimeout)

   at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate(Nullable`1 commandTimeout)

   at OpenAccessRuntime.Relational.metadata.RelationalLinkCollectionField.deleteOneByOne(CharBuf s, Connection con, Int32 blockStart, Int32 blockEnd, DeletePacket graph)

9 Answers, 1 is accepted

Sort by
0
Yassine
Top achievements
Rank 1
answered on 14 Dec 2014, 02:03 PM
please, anyone, this is blocking and kinda urgent!
0
Yassine
Top achievements
Rank 1
answered on 15 Dec 2014, 03:46 PM
Please, anyone ?
0
Doroteya
Telerik team
answered on 16 Dec 2014, 11:54 AM
Hello Yassine,

Based on the provided information, it seems that the delete statement tries to delete rows from a table that does not exist in the database schema (Banque_Compte). Such a mismatch between the model and the database schema usually happens when the two are not synchronised.

To fix this problem, you could use the Update Database From Model wizard and the following workflow:
1. Run the wizard as described here.
2. On the Select Changes Page, choose Create Database.
3. On the Summary Page, choose Create Script File.
4. Click the Finish button.
5. Open for edit the newly generated .sql file from Solution Explorer.
6. Remove all the SQL statements that are irrelevant to the Banque_Compte table. Basically, you have to end up with a CREATE TABLE statement for this table, two foreign key constraints and an index.
7. Execute the resulting SQL on the database.
8. Run the application for a test.

In case, the error continues to appear after applying the suggested workflow, I kindly ask you to provide us with a code snippet of the method that produces it, so that we can review it on our side.

Do let us know how the things are on your side. 



Regards,
Doroteya
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 18 Dec 2014, 08:18 PM
that didn't work at all, but this worked and created the needed tables
http://www.telerik.com/forums/the-object-name-'voa_keygen'-is-invalid#W_tE3wHd4Uqibndqv9VAgA
0
Doroteya
Telerik team
answered on 19 Dec 2014, 11:29 AM
Hello Yassine,

I am glad that currently things are working on your side.

Let me just add that the suggested workflow and the code you found basically produce one and the same outcome. The difference between them is that the suggested workflow gives you control over what exactly will be executed on the server.

I hope this helps. Do not hesitate to get back to us, if you need further information.


Regards,
Doroteya
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 19 Dec 2014, 11:32 AM
thanks, but it's weird how the code fixes it while the wizard doesn't, In fact, the wizard suggests to delete the join tables the code creates, weird conflict , but it's solved now, hope you guys look into it further more.
0
Doroteya
Telerik team
answered on 22 Dec 2014, 09:28 AM
Hi Yassine,

The difference you observe comes from the Update option selected in the wizard. Update option equal to Create Database will generate a brand new DDL script, that creates the database based on the model, while upgrade option Migrate Database with checked Allow table removal will generate DDL script only for the differences in the model that are not in the database and will suggest to you to delete the database tables that are not in the model. You can take a look at the attached screenshot.

I hope this helps. Let us know if you need further assistance.


Regards,
Doroteya
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 22 Dec 2014, 09:36 AM
if i let it delete the tables that aren't in the model, i'm back to square one, the exception, till i run the UpdateSchema method the guy in the other post wrote.
0
Doroteya
Telerik team
answered on 22 Dec 2014, 09:47 AM
Hi Yassine,

This, of course, is correct. That's why when Migrate Database is selected (with or without Allow table removal), you will observe a check-box next to each change. When the check-box is selected, a script for the particular change will be generated. When the check-box is unchecked, there will be no script for the change. Here is a list of articles from our documentation that will help you to get to know the wizard:

- Update Database From Model Feature Reference
How to: Update an Existing Database Schema
- General Scenarios: Handling Model Changes

I hope this helps. If you need further information, do let us know.


Regards,
Doroteya
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
Yassine
Top achievements
Rank 1
Doroteya
Telerik team
Share this question
or