public void Can_disable_AutoIncrement_field() { using (var db = OpenDbConnection()) { db.DropAndCreateTable<PersonWithAutoId>(); typeof(PersonWithAutoId) .GetModelMetadata() .PrimaryKey.AutoIncrement = false; var row = new PersonWithAutoId { Id = 100, FirstName = "Jimi", LastName = "Hendrix", Age = 27 }; db.Insert(row); row = db.SingleById<PersonWithAutoId>(100); Assert.That(row.Id, Is.EqualTo(100)); typeof(PersonWithAutoId) .GetModelMetadata() .PrimaryKey.AutoIncrement = true; } }
public void Save_populates_AutoIncrementId() { using (var db = OpenDbConnection()) { db.CreateTable<PersonWithAutoId>(overwrite: true); var row = new PersonWithAutoId { FirstName = "Jimi", LastName = "Hendrix", Age = 27 }; db.Save(row); Assert.That(row.Id, Is.Not.EqualTo(0)); } }