title: Entity Framework 5 Multiple identity columns specified for table. Only one identity column per table is allowed
body: <p>I am creating this model as part of my code first entity framework</p>
  
  <pre><code>public class NewUserRegistration
  {
      [Key]
      public int NewUserRegistrationId { get; set; }    
  }
  </code></pre>
  
  <p>Using the <code>Update-Database -Verbose -Force</code> command in the Package Manger ConsoleI get this exception during the this bit of the update <code>Applying automatic migration: 201211252223088_AutomaticMigration.</code></p>
  
  <blockquote>
    <p>ALTER TABLE [dbo].[NewUserRegistration] ADD [NewUserRegistrationId]
    [int] NOT NULL IDENTITY System.Data.SqlClient.SqlException
    (0x80131904): Multiple identity columns specified for table
    'NewUserRegistration'. Only one identity column per table is allowed. 
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
    Boolean breakConnection, Action<code>1 wrapCloseInAction)    at
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
    exception, Boolean breakConnection, Action</code>1 wrapCloseInAction)    at
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
    stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)    at
    System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,
    SqlCommand cmdHandler, SqlDataReader dataStream,
    BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
    stateObj, Boolean&amp; dataReady)    at
    System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String
    methodName, Boolean async, Int32 timeout)    at
    System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource<code>1
    completion, String methodName, Boolean sendToPipe, Int32 timeout,
    Boolean asyncWrite)    at
    System.Data.SqlClient.SqlCommand.ExecuteNonQuery()    at
    System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction
    transaction, MigrationStatement migrationStatement)    at
    System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction
    transaction, MigrationStatement migrationStatement)    at
    System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable</code>1
    migrationStatements)    at
    System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable<code>1
    migrationStatements)    at
    System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String
    migrationId, XDocument targetModel, IEnumerable</code>1 operations, Boolean
    downgrading, Boolean auto)    at
    System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String
    migrationId, XDocument sourceModel, XDocument targetModel, Boolean
    downgrading)    at
    System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.AutoMigrate(String
    migrationId, XDocument sourceModel, XDocument targetModel, Boolean
    downgrading)    at
    System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable<code>1
    pendingMigrations, String targetMigrationId, String lastMigrationId)<br>
    at
    System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable</code>1
    pendingMigrations, String targetMigrationId, String lastMigrationId)<br>
    at System.Data.Entity.Migrations.DbMigrator.Update(String
    targetMigration)    at
    System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String
    targetMigration)    at
    System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
    ClientConnectionId:a39395da-5f2b-48e0-bdac-b48d75a68c68 Multiple
    identity columns specified for table 'NewUserRegistration'. Only one
    identity column per table is allowed.</p>
  </blockquote>
  
  <p>There is plainly only one Identity Column specified. So why is this the case?</p>
  
  <p>When I do this I get no exception.</p>
  
  <pre><code>public class NewUserRegistration
  {
      [Key]
      public int Id { get; set; }    
  }
  </code></pre>
  
  <p>Any thoughts on why this is the case?</p>
  
  <p><em><strong>EDIT</em></strong></p>
  
  <p>I should say that I am changing the name of the key. The comments say that you can't just do this. How can I drop and recreate? </p>
  
  <p>Is it best to delete the database from SQL and then just run the <code>Update-Database</code> command again?</p>