I'm learning Entity Framework under VC# 2010.
I have created a simple table for learning purposes, one of the fields is "id" type integer, identity set to true. I've generated Entity Data Model from that table and connected it with dataGridView. The problem is that it doesn't auto increment - each inserted row wants to be id=0 (which is impossible of course, since id must be unique)
What am I doing wrong? How should I configure EF or the SQL db itself?
Check in your EDMX model, that the autoincrement field's StoreGeneratedPattern attribute is set to "Identity". In this way, EF knows that the autonumbers are handled by the DB.
Here this is explained better: Autonumber with Entity Framework
The identity isn't set and incremented just by adding to the entity set... The entity isn't actually saved to the db until you call context.SaveChanges()...
db.AddToUserSet(user);//Added to EF entity collection db.SaveChanges();//INSERT executed in db, Identity set and incremented.