You must specify your Guid ID as an identifier in your EF model. In EF 4.1:
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; }
( Guid identifiers are not identifiers by default, unlike int Ids.) If you create a database with this model, EF will create a column with a default value of newid() .
In EF 4.0, you can go to the model designer, mark your Id property in the constructor, open the properties window, and then set StoreGeneratedPattern to Identity .
Slauma
source share