Microsoft Developer Network > Forums Home > Data Platform Development (Pre-release) Forums > ADO.NET Entity Framework and LINQ to Entities (Pre-Release) > "Modifying a column with the 'Identity' pattern is not supported" exception occur while saving changes
Ask a questionAsk a question
 

Answer"Modifying a column with the 'Identity' pattern is not supported" exception occur while saving changes

  • Friday, October 23, 2009 9:25 AMDmitriano Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi All!

    I have a simple table "MyEntities" with identity column "Id" and I unable to save my changes if I get OptimisticConcurrencyException:
                    try
                    {
                        ctx.SaveChanges();
                    }
                    catch (OptimisticConcurrencyException)
                    {
                        ctx.Refresh(RefreshMode.ClientWins, ctx.MyEntities);
    
                        //at this point I get UpdateException whose innter exception contains this:
    		    //"Modifying a column with the 'Identity' pattern is not supported. Column: 'Id'.
                        ctx.SaveChanges();
                        
                        Console.WriteLine("OptimisticConcurrencyException handled and changes saved.");
                    }
    
    
    How do I handle this situation?

    Thanks.

Answers

  • Saturday, October 24, 2009 6:18 AMDiego B VegaMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello Dmitriano,

    Properties mapped to columns that are marked as store generated with the identity pattern cannot really be modified. I suspect the issue could be that some part of the code you use to modify the property values in your entities is attempting to do just that, but because you haven’t included that part of the code in your post, I cannot tell for sure.

    Hope this helps,
    Diego

    This posting is provided "AS IS" with no warranties, and confers no rights.

All Replies

  • Saturday, October 24, 2009 6:18 AMDiego B VegaMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello Dmitriano,

    Properties mapped to columns that are marked as store generated with the identity pattern cannot really be modified. I suspect the issue could be that some part of the code you use to modify the property values in your entities is attempting to do just that, but because you haven’t included that part of the code in your post, I cannot tell for sure.

    Hope this helps,
    Diego

    This posting is provided "AS IS" with no warranties, and confers no rights.