This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello! Any idea what can couse this error? I'm creating new object to insert it to table and while saving changes this error appears. Thanks |
|
|
Hi Webio, KeyTable is the name of the table that LightSpeed will look for when using the KeyTable identity method. If you want to use this identity method then create a KeyTable table (a script for this ships with LightSpeed). If you don't intend to use this pattern, change the indetity method on your LightSpeed Context to the identity method you want to use. Hope that helps, John-Daniel |
|
|
That was it. Thanks |
|
|
Using Lightspeed 2.2
Rather than start another thread.... :-) I'm having the same problem, only I've checked that the Identity method is set to Default in all Lightspeed entities. The entity in question doesn't have an Id field, but it does have a unique (non-null primary key (int) which Lightspeed correctly picked up and set the IdentityColumnName property to it. System.Data.SqlClient.SqlException: Invalid object name 'KeyTable'. | Stack: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 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) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteScalar() at ...() at ..(IUnitOfWork , IDbCommand , ) at ..(IUnitOfWork , IDbCommand ) at ..(IUnitOfWork ) at ..(IUnitOfWork ) at Mindscape.LightSpeed.Entity.GeneratedId() at Mindscape.LightSpeed.Entity`1.get_Id() at Mindscape.LightSpeed.Entity`1.get_IdInternal() at Mindscape.LightSpeed.UnitOfWork.Add(Entity entity) |
|
|
Hi Foggerty :) You are likely getting this because you dont have a KeyTable table in your database, if you add the contents of the KeyTable.sql script (located by default in: C:\Program Files\Mindscape\LightSpeed 2.2\Providers\SQLServer2005) into your database build then that should sort it. The script itself is very simple and you might want to change the seed value if you are inserting any default rows into your database. IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'KeyTable') |
|
|
I thought that if all of my entities had 'IdentityMethod' set to Default (which I do), it would default to using an identity column? Or is using a KeyTable the default under certain circumstances?
In other words, I shouldn't require a key table (I haven't so far). |
|
|
KeyTable is always the default. It can be overridden at the LightSpeedContext level (the normal case) or on a per-entity basis (if different entities require different identity methods). If IdentityMethod is set to Default on an entity, that means it uses the method specified on the LightSpeedContext. If no method is specified on the LightSpeedContext, it defaults to KeyTable. Could it be that previously your LightSpeedContext.IdentityMethod was set to IdentityColumn, but that this is no longer the case? In any case, the fix is probably to set LightSpeedContext.IdentityMethod to IdentityColumn (assuming that is what you want rather than KeyTable!). |
|
|
Ahhhh, enlightenment dawns. As well as embarrassment.
a) I hadn't set the context's identity method to IdentityColumn, BUT: b) this was the first time I've actually tried writing something back to the database, so until now it hadn't been an issue.... So my bad, and thanks, now I've updated the context the error has gone away. To be replaced with another, but I'll go through the docs for this one ;-) Cheers. |
|