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
|
Hi, I have a problem when I add a new record to my table. This is the code that I use: using (ModelUnitOfWork uow = Repository.Context.CreateUnitOfWork()) My table key is an autoincrement field named ID. When i try to add the new record (uow.Add(tMenuItems);) I've this error: "Table 'omega.keytable' doesn't exist" How do I do to auto-increment my ID?
Thanx |
|
|
Hi Antonio, You'll need to set your LightSpeedContext.IdentityMethod to use the IdentityMethod.IdentityColumn (you can either do this in code or in your .config file). Check out the help file for identity generation (you'll have a CHM under LightSpeed in your start menu but here's a link): http://www.mindscape.co.nz/products/lightspeed/Help/Help%20Topics/LightSpeed/IdentityGeneration.html LightSpeed uses a default of KeyTable for performance reasons which relies on there being a KeyTable in your database. Flip it over to Identity column and you should be fine :-) Also, while you're here - you do not need to have uow.Dispose(). The using() { } statement means that the uow will automatically be disposed when the using statement completes. This is why we use the using statement :-) I hope that helps, John-Daniel Trask |
|
|
Hi John-Daniel, Thanx for the reply and advice on. Dispose ()!
Thanx |
|
|
If you wanted to use KeyTable, you would need to make the following database changes: * Add a table named KeyTable, using the SQL script provided in the Providers directory. * Change your ID columns to be non-identity / non-autoincrement columns. (Because LightSpeed will now be sending IDs as part of the INSERT, and the database will get upset if you try to insert an explicit value into an identity/autoincrement column.) You would also need to set LightSpeedContext.IdentityMethod = KeyTable. |
|