Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8915215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:55:34+00:00 2026-06-15T04:55:34+00:00

I’ve never seen this happen before, very odd. I have a local SQL Server

  • 0

I’ve never seen this happen before, very odd.

I have a local SQL Server 2012 Express database that I’m developing against. Running a simple suite of tests using the TestDrive plugin and accessing the database with EF v5.

I just ran a test that inserts a record into the database. I had 9 rows in the table going from id 1-9. The next insert and the ID jumped by exactly 10000 !!!!

The Id column goes:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10009

I know failed inserts also increment the ID but I can guarantee that 10,000 didn’t fail to insert in the 5 seconds between test runs …

The table structure is really simple, a bunch of columns and one auto incrementing, identity column of type bigint (long), no SPs, triggers or any other programmatic content.

[Id] [bigint] IDENTITY(1,1) NOT NULL,

Very confusing, has anyone else seen this happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:55:35+00:00Added an answer on June 15, 2026 at 4:55 am

    This blog post has some additional details. It looks like in 2012, identity is implemented as a sequence. And by default, a sequence has a cache. If the cache is lost you lose the sequence values in the cache.

    The proposed solution is to create a sequence with no cache:

    CREATE SEQUENCE TEST_Sequence
        AS INT
        START WITH 1
        INCREMENT BY 1
        NO CACHE
    

    As far as I can see, the sequence behind an identity column is invisible. You can’t change it’s properties to disable caching.

    To use this with Entity Framework, you could set the primary key’s StoredGeneratedPattern to Computed. Then you could generate the identity server-side in an instead of insert trigger:

    if exists (select * from sys.sequences where name = 'Sequence1')
        drop sequence Sequence1
    if exists (select * from sys.tables where name = 'Table1')
        drop table Table1
    if exists (select * from sys.triggers where name = 'Trigger1')
        drop trigger Trigger1
    go
    create sequence Sequence1
        as int
        start with 1
        increment by 1
        no cache
    go
    create table Table1
        (
        id int primary key,
        col1 varchar(50)
        )
    go
    create trigger Trigger1
        on Table1
        instead of insert
    as
    insert  Table1
            (ID, col1)
    select  next value for Sequence1
    ,       col1
    from    inserted
    go
    insert Table1 (col1) values ('row1');
    insert Table1 (col1) values ('row2');
    insert Table1 (col1) values ('row3');
    
    select  * 
    from    Table1
    

    If you find a better solution, let me know 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.