title: Yii seems to neglect AUTO_INCREMENT for PrimaryKey
body: <p>primary keys in all tables(about 120) of our database are set to AUTO_INCREMENT.</p>
  
  <p>I noticed,that yii2 seems to neglect this guideline. 
  If I use to create a new record (without filling out PrimaryKey in formular, of course) new record will have an id, which is completely without foundation in fact.
  For instance, I have two records in table, which are created using phpmyadmin by id=1/id=2.
  New record,created using yii will have id 4191.
  Furthermore, I sometimes get error :</p>
  
  <pre><code>Duplicate entry for Primary Key
  </code></pre>
  
  <p>Any ideas,how to fix this probelm?</p>
  
  <p>Here is formular. id (Primay Key) will nowhere be filled out,'cause this value should be saved into database behind the scences!</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  use kartik\date\DatePicker;
  use \common\modules\basis\models\Person;
  use common\modules\lookup\models\LPersonArt;
  use kartik\widgets\FileInput;
  
  
  $id_person_art_bewerber = Person::find()-&gt;where(['id_person_art' =&gt; 1])-&gt;one()-&gt;id_person_art;
  $id_person_art_mitarbeiter = Person::find()-&gt;where(['id_person_art' =&gt; 3])-&gt;one()-&gt;id_person_art;
  
  $form = ActiveForm::begin([
              'id' =&gt; 'bewerber-view',
              'options' =&gt; [
                  'class' =&gt; 'form-horizontal']
          ]);
  ?&gt;
  &lt;?= $form-&gt;errorSummary($model); ?&gt;
  &lt;!-- START ACCORDION &amp; CAROUSEL--&gt;
  &lt;div class="row"&gt;
      &lt;div class="col-md-6"&gt;
          &lt;div class="box box-solid"&gt;
              &lt;div class="box-header with-border"&gt;
                  &lt;h3 class="box-title"&gt;Bitte hier zu-und aufklappen &lt;/h3&gt;
              &lt;/div&gt;
              &lt;!-- /.box-header --&gt;
              &lt;div class="box-body"&gt;
                  &lt;div class="box-group" id="accordion"&gt;
                      &lt;!-- we are adding the .panel class so bootstrap.js collapse plugin detects it --&gt;
                      &lt;div class="panel box box-primary"&gt;
                          &lt;div class="box-header with-border"&gt;
                              &lt;h4 class="box-title"&gt;
                                  &lt;a data-toggle="collapse" data-parent="#accordion" href="#collapseOne"&gt;
                                      Inputfelder der Personentabelle
                                  &lt;/a&gt;
                              &lt;/h4&gt;
                          &lt;/div&gt;
                          &lt;div id="collapseOne" class="panel-collapse collapse in"&gt;
                              &lt;div class="box-body"&gt;
                                  &lt;div class="bewerber-view"&gt;
                                      &lt;?=
                                      $form-&gt;field($model_person, 'angelegt_am')-&gt;widget(\kartik\datecontrol\DateControl::classname(), [
                                          'type' =&gt; \kartik\datecontrol\DateControl::FORMAT_DATETIME,
                                          'disabled' =&gt; true,
                                      ]);
                                      ?&gt;
                                      .
                                      .
                                      .
                                      &lt;!-- END ACCORDION &amp; CAROUSEL--&gt;
  &lt;?=
  $form-&gt;field($model, 'id_person')-&gt;widget(\kartik\widgets\Select2::classname(), [
      'data' =&gt; Person::getPerson($id_person_art_bewerber),
      'options' =&gt; ['placeholder' =&gt; Yii::t('app', 'Bitte geben sie den Nachnamen des Bewerbers über die DropDownbox ein')],
      'pluginOptions' =&gt; [
          'allowClear' =&gt; true,
      ],
  ]);
  ?&gt;
  .
  .
  .
  </code></pre>
  
  <p>Here is Controller:</p>
  
  <pre><code>    public function actionCreate() {
          //try {
  
          $model = new Bewerber(['scenario' =&gt; Bewerber::SCENARIO_CREATE]);
          $model_person = new Person(['scenario' =&gt; Person::SCENARIO_CREATE]);
          $behavior = new \common\wsl_components\Wsl_Blameable_Behavior();
          $angelegt_von = $behavior-&gt;get_User_Person_Id();
          if (!$model || !$model_person) {
              throw new NotFoundHttpException("Bitte überprüfen Sie die Validität der Tabellen bewerber bzw. person");
          }
          $model-&gt;angelegt_von = $angelegt_von;
          $model_person-&gt;angelegt_von = $angelegt_von;
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model_person-&gt;load(Yii::$app-&gt;request-&gt;post())) {
              $valid = $model-&gt;validate();
              $isValid = $model_person-&gt;validate();
              $isValid = $valid &amp; $isValid;
              if ($isValid) {
                  $model-&gt;avatar = UploadedFile::getInstances($model, 'avatar');
                  $model-&gt;upload();
                  $model_person-&gt;save();
                  $model-&gt;save();
                  return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
              } else {
                  $error_person = $model_person-&gt;getErrors();
                  $error_bewerber = $model-&gt;getErrors();
                  foreach ($error_person as $values) {
                      foreach ($values as $ausgabe) {
                          echo"&lt;p&gt;" . $ausgabe . "&lt;/p&gt;";
                      }
                  }
                  foreach ($error_bewerber as $values) {
                      foreach ($values as $ausgabe) {
                          echo"&lt;p&gt;" . $ausgabe . "&lt;/p&gt;";
                      }
                  }
                  echo Growl::widget([
                      'type' =&gt; Growl::TYPE_DANGER,
                      'title' =&gt; 'Oh snap!',
                      'icon' =&gt; 'glyphicon glyphicon-remove-sign',
                      'body' =&gt; 'Aus unbekannten Gründen konnten die Tabellen nicht validiert werden&lt;br&gt;Bitte informieren Sie den Hersteller gemäß obiger Angaben!',
                      'showSeparator' =&gt; true,
                      'delay' =&gt; 2000,
                      'pluginOptions' =&gt; [
                          'showProgressbar' =&gt; true,
                          'placement' =&gt; [
                              'from' =&gt; 'top',
                              'align' =&gt; 'center',
                          ]
                      ]
                  ]);
                  return $this-&gt;render('create', [
                              'model' =&gt; $model,
                              'model_person' =&gt; $model_person,
                  ]);
              }
          } else {
              return $this-&gt;render('create', [
                          'model' =&gt; $model,
                          'model_person' =&gt; $model_person,
              ]);
          }
          /* } catch (\Exception $error) {
            $go_back = "bewerber";
            \common\wsl_components\error_handling::error($error, $go_back);
            } */
      }
  </code></pre>
  
  <p>Models have been generated using gii of mootensai. If I should paste it,please tell me!</p>
  
  <p>Maybe, this behavior is 'caused by model using uuid-behavior of mootensai? If I delete this Behavior, I will get error like this</p>
  
  <pre><code>SQLSTATE[22003]: Numeric value out of range: 167 Out of range value for column 'id' at row 1
  The SQL being executed was: INSERT INTO `bewerber` (`angelegt_von`, `id_person`, `id_person_rekrutiert_von`, `id_abrechnungsweg`, `id_kanal`, `id_bewerberquelle`, `id_ba_xml_gelernter_beruf_1`, `id_ba_xml_gelernter_beruf_2`, `id_ba_xml_gelernter_beruf_3`, `umkreis`, `arbeitsuchend_seit`, `avgs`, `arbeitsumfang_vollzeit`, `avgs_betrag`, `ablaufdatum_avgs`, `wunschgehalt_brutto`, `beurteilung_fachlich`, `beurteilung_persoenlich`, `sonstiges`, `verfuegbar_ab`, `gesuchte_positionen`, `anschreiben`, `arbeitsumfang_teilzeit`, `arbeitszeit_bueroueblich`, `arbeitszeit_vormittag`, `arbeitszeit_nachmittag`, `arbeitszeit_abend`, `arbeitszeit_nacht`, `arbeitszeit_wochenende`, `schichtbereitschaft`, `wochenstunden_minimum`, `wochenstunden_maximum`, `bemerkung_intern`, `quereinsteiger`, `zeitarbeit`, `pkw`, `fuehrerschein_pkw`, `fuehrerschein_lkw`, `fuehrerschein_omnibus`, `reisebereitschaft`, `kandidat`, `kandidat_seit`, `veroeffentlichen_bewerberboerse`, `kontakt_halten`, `aktiv`, `zuletzt_deaktiviert_am`, `angelegt_am`, `optimistic_lock`, `aktualisiert_am`) VALUES (5, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10, NULL, 1, 1, 2000, NULL, 750, '', '', '', NULL, '', '', NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 10, 30, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 1, 1, 1, NULL, NOW(), 0, NOW())
   Error Info: Array(    [0] =&gt; 22003    [1] =&gt; 167    [2] =&gt; Out of range value for column 'id' at row 1
  </code></pre>
  
  <p>Here is UUID Behavior of mootensai in model:</p>
  
  <pre><code>    public function behaviors() {
          return [
              'timestamp' =&gt; [
                  'class' =&gt; TimestampBehavior::className(),
                  'createdAtAttribute' =&gt; 'angelegt_am',
                  'updatedAtAttribute' =&gt; 'aktualisiert_am',
                  'value' =&gt; new \yii\db\Expression('NOW()'),
              ],
              'uuid' =&gt; [
                  'class' =&gt; UUIDBehavior::className(),
                  'column' =&gt; 'id',
              ],
          ];
      }
  </code></pre>
  
  <p><strong>I got solution:</strong>
  I had to remove UUID class of mootensai in both models!!</p>