{"record":{"id":"951f414b2cd78089","repo":"dotnet/efcore","slug":"conflictingconfiguration-cannot-be-set-for-p","errorCode":null,"errorMessage":"'{conflictingConfiguration}' cannot be set for '{property}' at the same time as '{existingConfiguration}'. Remove one of these configurations.","messagePattern":"'(.+?)' cannot be set for '(.+?)' at the same time as '(.+?)'\\. Remove one of these configurations\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Metadata/Conventions/StoreGenerationConvention.cs","lineNumber":132,"sourceCode":"                Validate(declaredProperty, declaringTable);\n            }\n        }\n    }\n\n    /// <summary>\n    ///     Throws if there is conflicting store generation configuration for this property.\n    /// </summary>\n    /// <param name=\"property\">The property to check.</param>\n    /// <param name=\"storeObject\">The identifier of the store object.</param>\n    protected virtual void Validate(\n        IConventionProperty property,\n        in StoreObjectIdentifier storeObject)\n    {\n        if (property.TryGetDefaultValue(storeObject, out _))\n        {\n            if (property.GetDefaultValueSql(storeObject) != null)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.ConflictingColumnServerGeneration(\"DefaultValue\", property.Name, \"DefaultValueSql\"));\n            }\n\n            if (property.GetComputedColumnSql(storeObject) != null)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.ConflictingColumnServerGeneration(\"DefaultValue\", property.Name, \"ComputedColumnSql\"));\n            }\n        }\n        else if (property.GetDefaultValueSql(storeObject) != null)\n        {\n            if (property.GetComputedColumnSql(storeObject) != null)\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.ConflictingColumnServerGeneration(\"DefaultValueSql\", property.Name, \"ComputedColumnSql\"));\n            }\n        }\n    }","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Metadata/Conventions/StoreGenerationConvention.cs#L114-L150","documentation":"A relational column may use exactly ONE server-generation strategy. This throw fires from StoreGenerationConvention.Validate when a property has both a DefaultValue and a DefaultValueSql set for the same StoreObjectIdentifier, because the provider cannot decide which one to render into the DDL/migration. EF treats these as mutually exclusive on a single column.","triggerScenarios":"Calling both HasDefaultValue(...) and HasDefaultValueSql(...) on the same property in OnModelCreating (or in an IEntityTypeConfiguration), possibly split across partial classes or scaffolded code plus a manual override. The convention runs during model finalization when the property is mapped to a table.","commonSituations":"Reverse-engineering a table that has a default SQL expression and then adding HasDefaultValue in fluent config; copy-pasting column setup between entities; upgrading an older model where only DefaultValueSql existed and a developer added DefaultValue for clarity.","solutions":["Inspect the property named in the message and find both HasDefaultValue and HasDefaultValueSql calls across all configuration sources (fluent, attributes, scaffolded files, model snapshots).","Keep exactly one. If you want a literal CLR default, keep HasDefaultValue and delete HasDefaultValueSql; if you want a SQL expression (e.g. GETUTCDATE()), keep HasDefaultValueSql and delete HasDefaultValue.","Regenerate the migration so the column definition no longer emits both DEFAULT and the SQL expression."],"exampleFix":"// before\nmodelBuilder.Entity<Order>()\n    .Property(o => o.Created)\n    .HasDefaultValue(DateTime.UtcNow)\n    .HasDefaultValueSql(\"GETUTCDATE()\");\n\n// after\nmodelBuilder.Entity<Order>()\n    .Property(o => o.Created)\n    .HasDefaultValueSql(\"GETUTCDATE()\");","handlingStrategy":"validation","validationCode":"// Before configuring, ensure only one of the three is set for the store object\nvar prop = modelBuilder.Entity<Order>().Property(o => o.Created).Metadata;\nvar storeObj = StoreObjectIdentifier.Table(\"Orders\");\nif (prop.TryGetDefaultValue(storeObj, out _)\n    && prop.GetDefaultValueSql(storeObj) is not null)\n{\n    throw new InvalidOperationException(\"Cannot set both DefaultValue and DefaultValueSql on Created.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize each property's value-generation config in a single IEntityTypeConfiguration so two strategies cannot both be applied.","After scaffolding, audit any property that uses HasDefaultValue before adding HasDefaultValueSql.","Treat 'one of DefaultValue / DefaultValueSql / ComputedColumnSql per column' as a hard rule in code review."],"tags":["relational","model-building","store-generation","conventions"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}