title: SimpleMembership Provider not assigning ID's
body: <p>I'm trying to get an MVC4 site with SQL working using SimpleMembership, but I keep getting errors whenever I create a user record:</p>
  
  <pre><code>[SqlException (0x80131904): Cannot insert the value NULL into column 'Id', table 'NFBC.dbo.User'; column does not allow nulls. INSERT fails.
  The statement has been terminated.]
     System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +1753346
     System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5295154
     System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +242
     System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) +1682
     System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +269
     System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite) +1325
     System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean asyncWrite) +175
     System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +205
     System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +160
     WebMatrix.Data.Database.Execute(String commandText, Object[] args) +116
     WebMatrix.WebData.DatabaseWrapper.Execute(String commandText, Object[] parameters) +55
     WebMatrix.WebData.SimpleMembershipProvider.CreateUserRow(IDatabase db, String userName, IDictionary`2 values) +1074
     WebMatrix.WebData.SimpleMembershipProvider.CreateUserAndAccount(String userName, String password, Boolean requireConfirmation, IDictionary`2 values) +102
     WebMatrix.WebData.WebSecurity.CreateUserAndAccount(String userName, String password, Object propertyValues, Boolean requireConfirmationToken) +127
     NFBC.Controllers.AccountController.Register(RegisterModel model) in e:\PROJECTS\DEVELOPMENT\00-Current\NFBC\NFBC\Controllers\AccountController.cs:74
  </code></pre>
  
  <p>So to me this says that it's trying to insert a row into my user table but it's not setting the "Id" property, which is the primary key of the table. This ID is an int column as required by the provider. Here's how the code is running:</p>
  
  <pre><code>            WebSecurity.InitializeDatabaseConnection("NFBCEntitiesRaw", "User", "Id", "Email1", autoCreateTables: true);
              WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
  </code></pre>
  
  <p>Id is an int primary key column, Email1 is the username column, nvarchar(255).</p>
  
  <p>And the Connection string to the database:</p>
  
  <pre><code>&lt;add name="NFBCEntitiesRaw" connectionString="data source=localhost;initial catalog=NFBC;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework" providerName="System.Data.SqlClient" /&gt;
  </code></pre>
  
  <p>I've examined the source code for WebSecurity.CreateUserAndAccount, SimpleMembershipProvider.CreateUserAndAccount, and SimpleMembershipProvider.CreateUserRow, and at no point in any of those methods does the source code assign an ID to the User record, which would confirm why an exception is being thrown. But the method doesn't allow me to specify the ID, and when this sample was running against SQLExpress, it seemed to assign the ID just fine... so I'm not really sure what I'm doing wrong here.</p>
  
  <p>Thanks!</p>