In my simple class, I use data annotations to map properties to columns as such:
[Table("Member")]
public class Member
{
[Key]
public Guid MemberId { get; set; }
}
I can already write new members to my table, but MemberId always uses the new Guid (0000-000-00 ...) instead of the beautiful server created by Guid.
I saw scenarios in which people change some parameter called StoreGeneratedPattern in the EDMX file. But since I am using Code First, obviously I do not have this EDMX file ...
So how would I decide to solve this?
Any help is greatly appreciated.
UPDATE !!
Ok, just found the answer myself. You can use annotation.
[Table("Member")]
public class Member
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid MemberId { get; set; }
}
source
share