Yes, you must map your Key property. Let's assume you have an entity like: public class MyEntity { public virtual Guid Key { get; set; } ... } Then you can define DbContext derived class like: public class Context : DbContext { public DbSet MyEntities { get; private set; } public Context() : base("connection") { MyEntities = Set(); } protected override void OnModelCreating(ModelBuilder modelBuilder) { base. OnModelCreating(modelBuilder); modelBuilder.Entity().
HasKey(e => e. Key); modelBuilder.Entity() . Property(e => e.
Key) . HasDatabaseGeneratedOption(DatabaseGenerationOption. Identity); // Other mapping } } Or you can simply define your entity with Data Annotations: public class MyEntity { Key, DatabaseGenerated(DatabaseGeneratedOption.
Identity) public virtual Guid Key { get; set; } ... } Edit: This works if the mapping is used with existing database but if you want EF code-first to create database for you it will use normal (not sequential) guids! Check this question for possible solutions in case of database generation.
I want to use EF4 to map entity to a table that has sequential guid as a PK. According to this post http://leedumond.com/blog/using-a-guid-as-an-entitykey-in-entity-framework-4/ EF4 supports this but with edmx mapping. Is there a way to use the server generated Guids when using EF4 Code First and if yes how?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.