.net - SQL Server Sequential Guid as a key when using Entity Framework Code First -


I want to use EF4 to map the unit to a table, which has sequential guide as a PK . According to this post, EF4 supports it but with AdMax mapping. Is there a way to use server-made products while using EF4 code, and if so?

Yes, you have to map your key asset, assuming you have an organization:

  Public Class Menty {Receive {Public Virtual Guide; Set; } ...   

Then you can define DbContext as a derived class:

  Public category reference: DbContext {Public DbSet & lt; MyEntity & gt; My intents {receive; Private set; } Public context (): base ("connection") {MyEntities = set & lt; MyEntity & gt; (); } Safe Override Zero OnModelCreating (Modelbuilder Model Builder) {base.OnModelCreating (modelBuilder); Modlbilder Anti & lt; MyEntity & gt; (). Hake (e = & gt; c); Modlbilder Anti & lt; MyEntity & gt; (). Property (E = & gt; E.K.). Database-Generated Option (Database Generation Operation.); // other mapping}}   

or you can only define your unit with data annotation:

  public class keymap {[Key, DatabaseGenerated (DatabaseGeneratedOption.Identity)] Public Virtual Guide Key {get; Set; } ...   

Edit:

This works if mapping is used with the existing database but if you EF code will first use this normal (not sequential) grid to create a database for you! For possible solutions in the case of database generation

Comments