Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7458581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:27:59+00:00 2026-05-29T13:27:59+00:00

I tried to insert row to my entity in Entity Framework. It works good

  • 0

I tried to insert row to my entity in Entity Framework. It works good for first insert operation, but it doesn’t work for second insert operation. I use Framework 4, C# and FireBird database. This is my code part

rec = new T_MEDIAPLAN_REC();
//
//... initialization for T_MEDIAPLAN_REC
//
BossTVEntities.AddToT_MEDIAPLAN_REC(rec);
BossTVEntities.SaveChanges();

It give me this exception after second SaveChanges() calling:

"The changes to the database were committed successfully, but an error occurred 
while updating the object context. The ObjectContext might be in an inconsistent 
state. Inner exception message: AcceptChanges cannot continue because the 
object's key values conflict with another object in the ObjectStateManager. 
Make sure that the key values are unique before calling AcceptChanges."

I tryed to see DataBase. There are two inserted records in target entity with different Id. So, I don’t know what the reason of such behavior.

I use Visual Studio 2010 SP1 Professional, Firebird 2.5 with .NET provider, C#, .NET Framework 4.0

It doesn’t work for every entity in database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T13:28:00+00:00Added an answer on May 29, 2026 at 1:28 pm

    This error usually happens when the primary key is generated in the database, but the EF is not properly configured read the value back from the database after the insert. As the result, both inserted items end up with an empty key in the EF context, triggering the error.

    Since the inserted data has different keys in the database, your DB schema appears to be correct. You need to check your EDM to see that StoreGeneratedPattern on the PK column is set to Identity or whatever it should be in firebird.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Tried a bunch of things but I can't get it to work consistently amid
On insert I am catching the unique constraint mysql_errno() 1062. This works fine but
I tried to insert a base64 encoded string into my SQLite database, but when
I insert a value / new row and I need the ID, but I
net and I'm trying to insert a row into an entity, and I keep
I created MVC ASP.Net Web application and tried insert Thai language data to SQL
I'm going crazy today. I just tried to insert a new record and it
I tried running the following statement: INSERT INTO VOUCHER (VOUCHER_NUMBER, BOOK_ID, DENOMINATION) SELECT (a.number,
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo
Tried following the instructions here: How to use Google app engine with my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.