HichemSeeSharp
HichemSeeSharp

Reputation: 3318

Autogenerate GUID at SaveChanges()

Is there any solution or update to make EntityFramework detects uniqueidentifier columns with default value newid(), when generating the enitiy model ?

Upvotes: 0

Views: 227

Answers (1)

Slauma
Slauma

Reputation: 177173

No. EF doesn't support (yet?) to define custom conventions. (One of the first CTPs for DbContext contained a first proposal for custom conventions but they have been removed in the final release due to the complexity of this feature. I don't know if or when they will return in a later release.) You have to live with the standard conventions available and they say that a property of type Guid isn't database generated by default. You must mark Guid properties explicitly with data annotations or Fluent API to override this default.

Upvotes: 1

Related Questions