-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow default value check in value generation to be customized #701
Comments
See also the discussion in #15070 (comment) Use of a different sentinel value could be useful here if it is set to the same as the default value.
|
This could be more relevant with non-nullable reference types. For example, non-nullable string properties can no longer default to null (unless bang is used), so it makes sense for many cases to initialize it e.g. to an empty string. But EF still uses null as the uninitialized sentinel value (to trigger value generation). |
…as not been set Fixes #701 Part of #13224, #15070, #13613 This PR contains the underlying model and change tracking changes needed to support sentinel values. Future PRs will add model building API surface and setting the sentinel automatically based on the database default. There is a breaking change here: explicitly setting the value of a property with a temporary value no longer automatically makes the value non temporary.
…as not been set Fixes #701 Part of #13224, #15070, #13613 This PR contains the underlying model and change tracking changes needed to support sentinel values. Future PRs will add model building API surface and setting the sentinel automatically based on the database default. There is a breaking change here: explicitly setting the value of a property with a temporary value no longer automatically makes the value non temporary.
Currently we generate a value for a property on Add when it is marked as needing value generation in metadata and the current value is the default for the type of property. It should be possible to customize the latter check to change the this sentinel value, make it a more complex check (e.g. negative numbers) or so that values are always generated regardless of the current value. This is probably best done with a Func in the model, but note this requires we implement the ability to annotate a model with code snippets.
The text was updated successfully, but these errors were encountered: