1

I'm using Mindscape.Lightspeed and getting the following error: Error: Invalid object name 'KeyTable'.

LightSpeedContext<LightSpeedModel1UnitOfWork> context = new LightSpeedContext<LightSpeedModel1UnitOfWork>("Development");

        using (var uow = context.CreateUnitOfWork())
        {
            SiteUser user = new SiteUser();
            user.UserName = "ABC";
            user.RoleId = 1;

            uow.Add(user);

        }
Myster
  • 17,704
  • 13
  • 64
  • 93
hotcoder
  • 3,176
  • 10
  • 58
  • 96

2 Answers2

4

I posted this commment on the official forum where you also posted this question :-)

This error message is being generated because you're using the KeyTable identity method. The Identity Method is how LightSpeed will generate identifiers for your entities and, by default, uses the KeyTable pattern. This requires a table called "KeyTable" (there is a script for this in the LightSpeed installation directory under the providers folder).

If you don't want to use the KeyTable identity method please configure an appropriate method on your LightSpeedContext configuration in the .config file. There is information about the various methods in the help file, in the getting started screencast and in some of the samples.

You can read the help file page online here:

http://www.mindscape.co.nz/Help/LightSpeed/Help%20Topics/LightSpeed/IdentityGeneration.html

I hope that helps,

John-Daniel

traskjd
  • 1,008
  • 5
  • 7
  • Here's a direct link to the help JD mentions: http://www.mindscapehq.com/documentation/lightspeed/Controlling-the-Database-Mapping/Identity-Generation – Myster Sep 06 '12 at 07:42
0

To save you a step or two, here's the SQL from the Lightspeed install folder to create the KeyTable in SQL Server 2008 (C:\Program Files (x86)\Mindscape\LightSpeed\Providers\SQLServer2008)

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'KeyTable')
BEGIN
  DROP TABLE KeyTable
END;

CREATE TABLE KeyTable
(
  NextId INT NOT NULL
)

INSERT INTO KeyTable VALUES (1);
Matt Kemp
  • 2,742
  • 2
  • 28
  • 38