Asp.Net Hein

Asp.Net Hein

  • NA
  • 266
  • 166.2k

Database error

Jul 30 2015 10:46 PM
I am facing this error when I upload excel file to the database...
 
If I check database after I saw this message, there is no data in database. 
 
Can anyone help me in my problem?
Thanks a lot for viewing my question. :-)
 
System.InvalidOperationException: 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: Saving or accepting changes failed because more than one entity of type 'SL1.course' have the same primary key value. Ensure that explicitly set primary key values are unique. Ensure that database-generated primary keys are configured correctly in the database and in the Entity Framework model. Use the Entity Designer for Database First/Model First configuration. Use the 'HasDatabaseGeneratedOption" fluent API or 'DatabaseGeneratedAttribute' for Code First configuration. ---> System.InvalidOperationException: Saving or accepting changes failed because more than one entity of type 'SL1.course' have the same primary key value. Ensure that explicitly set primary key values are unique. Ensure that database-generated primary keys are configured correctly in the database and in the Entity Framework model. Use the Entity Designer for Database First/Model First configuration. Use the 'HasDatabaseGeneratedOption" fluent API or 'DatabaseGeneratedAttribute' for Code First configuration. at System.Data.Entity.Core.Objects.ObjectStateManager.FixupKey(EntityEntry entry) at System.Data.Entity.Core.Objects.EntityEntry.AcceptChanges() at System.Data.Entity.Core.Objects.ObjectContext.AcceptAllChanges() at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) --- End of inner exception stack trace --- at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction) at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.b__27() at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation) at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction) at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options) at System.Data.Entity.Internal.InternalContext.SaveChanges() at System.Data.Entity.Internal.LazyInternalContext.SaveChanges() at System.Data.Entity.DbContext.SaveChanges() at SL1.UI.AddCourse.lbtSave_Click(Object sender, EventArgs e) in c:\Users\SelimSG-02\Desktop\Server files\SL1-7.28\SL1\SL1\UI\UploadCourse.aspx.cs:line 226

Answers (2)