{"record":{"id":"499e725b0ad1e8a0","repo":"dotnet/efcore","slug":"required-properties-requiredproperties-are-mis","errorCode":null,"errorMessage":"Required properties '{requiredProperties}' are missing for the instance of entity type '{entityType}' with the key value '{keyValue}'.","messagePattern":"Required properties '(.+?)' are missing for the instance of entity type '(.+?)' with the key value '(.+?)'\\.","errorType":"exception","errorClass":"DbUpdateException","httpStatus":null,"severity":"error","filePath":"src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs","lineNumber":397,"sourceCode":"    }\n\n    private static bool IsNullable(IProperty property)\n        => property.IsNullable\n            || (property.DeclaringType is IComplexType complexType\n                && IsNullable(complexType.ComplexProperty));\n\n    private static bool IsNullable(IComplexProperty property)\n        => property.IsNullable\n            || (property.DeclaringType is IComplexType complexType\n                && IsNullable(complexType.ComplexProperty));\n\n    private void ThrowNullabilityErrorException(\n        IUpdateEntry entry,\n        IList<IProperty> nullabilityErrors)\n    {\n        if (_sensitiveLoggingEnabled)\n        {\n            throw new DbUpdateException(\n                InMemoryStrings.NullabilityErrorExceptionSensitive(\n                    nullabilityErrors.Format(),\n                    entry.EntityType.DisplayName(),\n                    entry.BuildCurrentValuesString(entry.EntityType.FindPrimaryKey()!.Properties)),\n                [entry]);\n        }\n\n        throw new DbUpdateException(\n            InMemoryStrings.NullabilityErrorException(\n                nullabilityErrors.Format(),\n                entry.EntityType.DisplayName()),\n            [entry]);\n    }\n\n    /// <summary>\n    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n    ///     any release. You should only use it directly in your code with extreme caution and knowing that","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs#L379-L415","documentation":"During Create/Update the InMemory store detected that one or more non-nullable properties had a null value, and EnableSensitiveDataLogging() is on, so the entity key value is included in the message (InMemoryTable.cs:397-402). This is a DbUpdateException, not a concurrency error.","triggerScenarios":"Calling SaveChanges on an entity (insert or update) where a property declared as non-nullable (IsNullable == false, not a nullable complex type) resolves to null at store time, with EnableSensitiveDataLogging enabled.","commonSituations":"Forgetting to set a required property, a value converter returning null, or a computed/default value not being applied. Sensitive logging variant appears in dev/test where EnableSensitiveDataLogging is configured.","solutions":["Set the required property to a non-null value before calling SaveChanges.","If nulls are legitimately possible, make the property nullable in the model.","Provide a value generator or HasDefaultValue so the store can supply a value."],"exampleFix":"// before\ndb.Add(new Order { CustomerId = 1 }); // Total (required) missing\ndb.SaveChanges();\n// after\ndb.Add(new Order { CustomerId = 1, Total = 0m });\ndb.SaveChanges();","handlingStrategy":"validation","validationCode":"// Before SaveChanges, verify required (non-nullable) scalar properties are set:\nforeach (var entry in ctx.ChangeTracker.Entries())\n{\n    foreach (var prop in entry.Metadata.GetProperties())\n    {\n        if (!prop.IsNullable\n            && entry.CurrentValues[prop] is null\n            && prop.ValueGenerated == ValueGenerated.Never)\n        {\n            throw new InvalidOperationException($\"{entry.Entity.GetType().Name}.{prop.Name} is required but null.\");\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    ctx.SaveChanges();\n}\ncatch (DbUpdateException ex) when (ex.Message.Contains(\"Required properties\"))\n{\n    // identify and set the null required property, then retry\n}","preventionTips":["Validate required properties in domain code or via data annotations before SaveChanges.","Use HasDefaultValue or value generators for store-supplied required values.","EnableSensitiveDataLogging in dev/test to quickly identify the offending entity and key."],"tags":["ef-core","in-memory-provider","savechanges","validation","required-property"],"analyzedSha":"dbf9771522148d61a2467854921bd5dc6f6e6916","analyzedAt":"2026-08-06T20:46:03.226Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}