This question, asked a year ago, is similar: Does the Entity Framework 4 support generators for id values like NHibernate?
But what I\'d like to know is if the code
No.
Mine Entity Framework 4.1.10715 installed by NuGet. maybe you could use attribute
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id {get;set;}
please see (The full list of annotations supported in EF 4.1 : CTRL+F in page) here.