title: Prevent SQLAlchemy from automatically setting IDENTITY_INSERT
body: <p>I have a SQL Server table with an auto-incrementing primary key that I am manipulating using SQLAlchemy.  If I create an instance of that table's model that includes the primary key instead of leaving it off and call <code>session.add(instance)</code>, SQLAlchemy automatically issues <code>SET IDENTITY_INSERT [table] ON</code> to the database and the insert succeeds.  </p>
  
  <p>Is there a way to control this myself instead?  I'd rather get an error if I try to insert a specific primary key instead of letting it be auto-incremented.  If I really need to set the primary key, I'd rather have to explicitly tell it so.</p>
  
  <p>Here's the model:</p>
  
  <pre><code>Base = declarative_base()
  
  class Tub(Base):
      __tablename__ = 'Tub'
  
      id = Column('ID', Integer, primary_key=True, autoincrement=True)
      tare_weight = Column('TareWeight', Float(53), nullable=False)
  </code></pre>
  
  <p>Here's an example insert:</p>
  
  <pre><code>t = Tub(id=20, tare_weight=200)
  session.add(t)
  session.commit()
  </code></pre>
  
  <p>Here is the resulting SQL:</p>
  
  <pre><code>BEGIN
  SET IDENTITY_INSERT [Tub] ON
  INSERT INTO [Tub] ([ID], [TareWeight]) VALUES (20, 200)
  SET IDENTITY_INSERT [Tub] OFF
  COMMIT
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Another relevant situation I've realized is this:</p>
  
  <pre><code>t = Tub(id=20, tare_weight=200)
  session.merge(t)
  session.commit()
  </code></pre>
  
  <p>If the tub already exists in the database, I want its weight to be updated.  If it doesn't, I want the insertion to fail since it includes an explicit primary key.</p>