Assign database before setting autoincrement key.