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
|
I'm trying to use SQL Server IDENTITY column for PK generation with LightSpeed. I have an Entity created in my LS model, I have set the IdentityMethod to "IdentityColumn" on the Entity in the designer, and in the context configuration. I have also specified "Id" in the Entity designer "Identity Column Name" field and then did a right-click "update database" operation. But my "Id" column for this table in the database is still not set to an Identity column when I look at it in SQL Management Studio. What's the correct process to use SQL Server IDENTITY PK's ? I'm mainly doing it this way because it's what I'm used to working with at the database level. I'm not familiar with the advantages/benefits of the "KeyTable" approach that seems to be the LS default. |
|
|
Unfortunately, the database updater doesn't check for changes in the identity method. What probably happened is that the identity method wasn't set when you did the initial table creation, so the column was created as non-IDENTITY. Once that's happened, the designer won't try to change it. If you want to use identity PKs, you will therefore need to go into SQL Server Management Studio and set the Id column to have an identity specification. The advantage of KeyTable is efficiency. If you use identity keys, it defeats batching because LightSpeed has to get the ID allocated by SQL Server after every INSERT. So instead of issuing a batch of 10 INSERTs, LightSpeed has to issue 10 separate INSERTs, each followed by a SCOPE_IDENTITY(). With a KeyTable, LightSpeed can grab a block of IDs, can dole them out to entities without needing to consult the database again, and can then commit those entities in one batch. Note however that LightSpeed will not create the KeyTable automatically for you -- but we do provide the necessary SQL script (in the Providers directory). There's some discussion of the tradeoffs here: http://www.mindscape.co.nz/blog/index.php/2007/08/26/lightspeed-identity-generation/ http://www.mindscape.co.nz/blog/index.php/2008/09/18/saving-large-numbers-of-entities-in-lightspeed/ may also be worth a look depending on your application. |
|