title: Insert a specific id into auto incremented field in MySQL with Entity Framework 5
body: <p>So this i my situation.</p>
  
  <p>I have an old database with a lot, and I mean a LOT of data. However I've ended up creating a new database structure and now I want to move data from the old database into the new one. Being a programmer I'm not keen on doing it manually which is why I made a program to do just that.</p>
  
  <p>Now here is my problem: When adding a new item into the new database I'm unable to set it's id, which is crucial for the different link references and general foreign key references that exists in the old database.</p>
  
  <p>My question is therefore: How would I be able to insert an <em>specified id</em> integer into a field that has <strong>auto_increment</strong> in my <strong>MySQL</strong> database via <strong>Entity Framework 5</strong> which uses database first in <strong>C#</strong>?</p>
  
  <p><br/></p>
  
  <p>This is my MySQL script for the new database:</p>
  
  <pre><code>    CREATE TABLE Profile
      (
          _id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
          UNIQUE KEY(_id),
          etc etc
      )
  </code></pre>
  
  <p><br/>
  My insert code:</p>
  
  <pre><code>    public Profile Add(Profile item)
      {
          if (item == null)
          {
              throw new ArgumentNullException("item");
          }
  
          db.Entry(item).State = EntityState.Added;
          db.SaveChanges();
          return item;
      }
  </code></pre>
  
  <p>On an end note I whould like to inform that I know this is bad practise in general, but the database is empty and the id inserted are auto generated and unique from the old database which will ensure that no dublicates will occour</p>