{"record":{"id":"f6cc36e01eed0420","repo":"dotnet/efcore","slug":"required-properties-requiredproperties-are-mis-f6cc36","errorCode":null,"errorMessage":"Required properties '{requiredProperties}' are missing for the instance of entity type '{entityType}'. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the entity key value.","messagePattern":"Required properties '(.+?)' are missing for the instance of entity type '(.+?)'\\. Consider using 'DbContextOptionsBuilder\\.EnableSensitiveDataLogging' to see the entity key value\\.","errorType":"exception","errorClass":"DbUpdateException","httpStatus":null,"severity":"error","filePath":"src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs","lineNumber":405,"sourceCode":"        => 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\n    ///     doing so can result in application failures when updating to a new Entity Framework Core release.\n    /// </summary>\n    protected virtual void ThrowUpdateConcurrencyException(\n        IUpdateEntry entry,\n        Dictionary<IProperty, object?> concurrencyConflicts,\n        IDiagnosticsLogger<DbLoggerCategory.Update> updateLogger)\n    {\n        var entries = new[] { entry };","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/dotnet/efcore/blob/dbf9771522148d61a2467854921bd5dc6f6e6916/src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs#L387-L423","documentation":"Same nullability failure as 329 but with EnableSensitiveDataLogging OFF, so the key value is omitted and the message instead suggests enabling it to see the key (InMemoryTable.cs:405-409). A non-nullable property was null during Create/Update.","triggerScenarios":"Saving an entity where a non-nullable property resolves to null, without EnableSensitiveDataLogging configured.","commonSituations":"Production/default config where sensitive data logging is disabled. Forgetting required fields or value converters yielding null.","solutions":["Set the required property to a non-null value before SaveChanges.","Temporarily enable EnableSensitiveDataLogging() in a dev build to identify the offending entity/key (this switches the error to 329 which shows the key).","Make the property nullable or provide a default value/generator."],"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    // enable EnableSensitiveDataLogging in dev to see the key, then set the property\n}","preventionTips":["Validate required properties before SaveChanges.","Enable EnableSensitiveDataLogging() in a dev build to switch to the message that shows the entity key.","Provide defaults or value generators for store-supplied required values."],"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"}