Click here to Skip to main content
15,906,455 members
Home / Discussions / C#
   

C#

 
GeneralRe: dictionary/list help needed Pin
yoni.kess6-Oct-13 5:51
yoni.kess6-Oct-13 5:51 
GeneralRe: dictionary/list help needed Pin
Richard MacCutchan6-Oct-13 6:22
mveRichard MacCutchan6-Oct-13 6:22 
GeneralRe: dictionary/list help needed Pin
yoni.kess6-Oct-13 10:10
yoni.kess6-Oct-13 10:10 
GeneralRe: dictionary/list help needed Pin
Richard MacCutchan6-Oct-13 20:44
mveRichard MacCutchan6-Oct-13 20:44 
AnswerRe: dictionary/list help needed Pin
BillWoodruff6-Oct-13 16:58
professionalBillWoodruff6-Oct-13 16:58 
GeneralRe: dictionary/list help needed Pin
yoni.kess6-Oct-13 21:39
yoni.kess6-Oct-13 21:39 
GeneralRe: dictionary/list help needed Pin
BillWoodruff7-Oct-13 0:39
professionalBillWoodruff7-Oct-13 0:39 
QuestionEntity Framework: Primary key violation Pin
Lutosław6-Oct-13 2:55
Lutosław6-Oct-13 2:55 
I try to add an object to a database, but I get an exception
Code:
DataModelContainer cont = new DataModelContainer();

(...)
cont.AddToStudentSet(cont.StudentSet.CreateObject());
cont.SaveChanges();

After running the code twice, I get:
Exception:
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.

The Id of Student has an AutoIncrement set to TRUE in the database. On the first run a single Student record is created with Id 0. Later, no data is saved to the table at all.
The reason of why is it happening seems to be obvious, but it should work anyway.
Any help appreciated
Greetings - Jacek


modified 6-Oct-13 9:04am.

AnswerRe: Entity Framework: Primary key violation Pin
Dave Kreskowiak6-Oct-13 6:28
mveDave Kreskowiak6-Oct-13 6:28 
GeneralRe: Entity Framework: Primary key violation Pin
Lutosław6-Oct-13 9:50
Lutosław6-Oct-13 9:50 
Questionupdate ConnectionString in App.config Pin
Jassim Rahma6-Oct-13 0:03
Jassim Rahma6-Oct-13 0:03 
AnswerRe: update ConnectionString in App.config Pin
OriginalGriff6-Oct-13 0:10
mveOriginalGriff6-Oct-13 0:10 
QuestionSimple cross threading question Pin
ve3tru5-Oct-13 17:55
ve3tru5-Oct-13 17:55 
AnswerRe: Simple cross threading question Pin
Abhinav S5-Oct-13 19:00
Abhinav S5-Oct-13 19:00 
GeneralRe: Simple cross threading question Pin
ve3tru6-Oct-13 16:03
ve3tru6-Oct-13 16:03 
AnswerRe: Simple cross threading question Pin
Dave Kreskowiak6-Oct-13 4:24
mveDave Kreskowiak6-Oct-13 4:24 
AnswerRe: Simple cross threading question Pin
Richard MacCutchan6-Oct-13 5:04
mveRichard MacCutchan6-Oct-13 5:04 
Questionget pixel color on image Pin
Member 102255295-Oct-13 4:51
Member 102255295-Oct-13 4:51 
AnswerRe: get pixel color on image Pin
BillWoodruff5-Oct-13 7:22
professionalBillWoodruff5-Oct-13 7:22 
AnswerRe: get pixel color on image Pin
Richard MacCutchan5-Oct-13 20:51
mveRichard MacCutchan5-Oct-13 20:51 
AnswerRe: get pixel color on image Pin
AngloThaiSolutions7-Oct-13 4:01
AngloThaiSolutions7-Oct-13 4:01 
QuestionFocus of the DevExpress DateEdit Pin
nhanlaptrinh3-Oct-13 22:10
nhanlaptrinh3-Oct-13 22:10 
AnswerRe: Focus of the DevExpress DateEdit Pin
Eddy Vluggen4-Oct-13 0:25
professionalEddy Vluggen4-Oct-13 0:25 
QuestionVisual Studio Add-in 2012 Pin
Shankarcodebase3-Oct-13 21:41
Shankarcodebase3-Oct-13 21:41 
AnswerRe: Visual Studio Add-in 2012 Pin
Eddy Vluggen4-Oct-13 0:25
professionalEddy Vluggen4-Oct-13 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.