mardi 22 mars 2016

Entity Framework - Determine the HasDatabaseGeneratedOption setting for a given type

For some of the properties in my DB I need to manually calculate their Id #, so for those properties I do .Property(p => p.Id).HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.None); inside OnModelCreating

Then, in the repository I have a method to calculate out the Id for a given type. I would prefer to have the system be intelligent and check to see if the DatabaseGeneratedOption.None or DatabaseGeneratedOption.Identity and either return the next Id or 0.

How can I check (from inside a repository) what the DatabaseGeneratedOption for a given type (T) is?





Aucun commentaire:

Enregistrer un commentaire