c# - How to generate custom keys in EF7? -
ef7 usual stuff auto-generating auto-incrementing ids, adding [key]
attribute integral key. found video describes alternative strategy generating integer keys natively supported ef.
the keys in project, however, guids. , part want them generated comb guids, don't cause trouble on insertion clustered index. set default value of newsequentialid()
on sql table, want generate ids in code (which why we're using guids in first place). question 1 is: how generate comb guids on key field in ef7?
then there's particular table id field needs generated hash of 1 of fields. (this can rely on identical records in different environments having same id.) question 2 is: how implement custom guid generation on inserting records in table?
i tinkered in dbcontext
's onmodelcreating()
method, valuegeneratedonadd()
method, can't find parameters or overloads allow me set kind of custom guid generation.
Comments
Post a Comment