1

We are wanting to use application generated GUIDs with EF Core, but are looking to use COMB GUIDs to have them ordered sequentially, instead of relying on the guids being generated by EF Core out of box.

Does anyone know of an easy way to override/extend the default functionality of guid generation for new entities? I think we can do it on a per-entity basis using the Fluent API, but a global solution would definitely be preferred.

Devon Bessemer
  • 34,461
  • 9
  • 69
  • 95
  • Have you tried `defaultValueSql`? https://stackoverflow.com/questions/23081096/entity-framework-6-guid-as-primary-key-cannot-insert-the-value-null-into-column – Guvante Sep 19 '19 at 17:38
  • @Guvante that would be db generated though, right? Since we want the Guid before we persist the data, we want application generated. – Devon Bessemer Sep 19 '19 at 17:41
  • Are you using actual `Guid`s as primary keys, or are you keeping the default string key type and looking to generate different GUID values for those strings? – madreflection Sep 19 '19 at 17:44
  • @madreflection guids as primary keys – Devon Bessemer Sep 19 '19 at 17:52
  • 1
    Looking at the documentation the fluent API supports `HasValueGenerator()` which does what you are looking for I think. – Guvante Sep 19 '19 at 17:52

0 Answers0