title: Why EFContextProvider 1.4.16 throws DbUpdateConcurrencyException when trying to update Enum value?
body: <p>I'm trying to save a single change - an enum property value update.  EFContextProvider.SaveChanges() is called on the server, but generated SQL is wrong and when executed by the EFContextProvider it throws System.Data.Entity.Infrastructure.DbUpdateConcurrencyException.</p>
  
  <p>The enum property is defined like this:</p>
  
  <pre><code>        public virtual System.Nullable&lt;StanZleceniaOplaty&gt; Stan { get; set; }
  
          public enum StanZleceniaOplaty : int
          {
                      Created,
                      Started,
                      Canceled,
                      Rejected,
                      Paid
          }
  </code></pre>
  
  <p>EntityTypeConfiguration for entity ZlecenieOplaty configures Stan with the following code:</p>
  
  <pre><code>        this
              .Property(p =&gt; p.Stan)
                  .IsConcurrencyToken()
                  .HasColumnType("int"); 
  </code></pre>
  
  <p>Please note that this enum property <strong>IsConcurrencyToken</strong>.</p>
  
  <p>I'm changing the enum from Created to Canceled and calling SaveChanges().
  I can see that the SQL generated by EFContextProvider agains the EF 6.1 DB is wrong ([Stan] is not changed, because @0 == @2, @2 has wrong value - should be 0).</p>
  
  <pre><code>exec sp_executesql N'UPDATE [dbo].[ZlecenieOplaty]
  SET [Stan] = @0
  WHERE (([Id] = @1) AND ([Stan] = @2))
  SELECT [NrZlecenia]
  FROM [dbo].[ZlecenieOplaty]
  WHERE @@ROWCOUNT &gt; 0 AND [Id] = @1',
  N'@0 int,@1 int,@2 int',
  @0=2,
  @1=3,
  @2=2
  </code></pre>
  
  <p>In effect the following exception is thrown.</p>
  
  <pre><code>System.Data.Entity.Infrastructure.DbUpdateConcurrencyException occurred
    HResult=-2146233087
    Message=Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.
    Source=EntityFramework
    StackTrace:
         at System.Data.Entity.Internal.InternalContext.SaveChanges()
         at Alcance.Entities.AlcanceDbContext.SaveChanges() in d:\Develop\alcance\src\dev\Alcance.Data\Model\AlcanceModel.AlcanceDbContext.Connection.cs:line 121
    InnerException: System.Data.Entity.Core.OptimisticConcurrencyException
         HResult=-2146233087
         Message=Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.
         Source=EntityFramework
         StackTrace:
              at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.ValidateRowsAffected(Int64 rowsAffected, UpdateCommand source)
              at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
              at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
              at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
              at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
              at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
              at System.Data.Entity.Internal.InternalContext.SaveChanges()
         InnerException:
  </code></pre>
  
  <p>I opened <a href="https://github.com/Breeze/breeze.server.net/issues/8" rel="nofollow" title="issue #8">https://github.com/Breeze/breeze.server.net/issues/8</a>.</p>
  
  <p>Can anybody confirm that this is a bug?</p>