EntityFramework 4 - Adding a object without Identity column throws OptimisticConcurrencyException RRS feed

  • General discussion

  • Hi,

     I have a database first approach, using EF4 on Sybase.


        <EntityType Name="tq_qmt_logger">
        <PropertyRef Name="qmt_id" />
        <Property Name="qmt_id" Type="bigint" Nullable="false" StoreGeneratedPattern="Identity"  />
        <Property Name="client_id" Type="varchar" Nullable="false" MaxLength="100" />
        <Property Name="logged_date" Type="datetime" Nullable="false" />


    I have corresponding CSDL with annotation:StoreGeneratedPattern="Identity"

    Now my source code is,

       tq_qmt_logger qmtLogger = new tq_qmt_logger();
       qmtLogger.client_id = machineID;
       qmtLogger.logged_date = DateTime.Now;
       //qmtlogger.qmt id is omitted because it is
       // generated by a sequence in the DB.

    SaveChanges throws OptimisticConcurrencyException with error Store update, insert, or delete statement affected an unexpected number of rows (0). My guess is, EF passes 0 to my qmt_id (identity) column, which is getting rejected. Can someone guide how to fix this?
    Friday, October 9, 2015 1:22 AM

All replies

  • Hello There,

    Please refer below link


    Wednesday, October 14, 2015 11:36 AM