{"record":{"id":"eabc9557fa89c01f","repo":"dotnet/efcore","slug":"the-property-entitytype-property-is-mapped-t-eabc95","errorCode":null,"errorMessage":"The property '{entityType}.{property}' is mapped to a result column of the stored procedure '{sproc}', but it is also mapped to an output parameter. A store-generated property can only be mapped to one of these.","messagePattern":"The property '(.+?)\\.(.+?)' is mapped to a result column of the stored procedure '(.+?)', but it is also mapped to an output parameter\\. A store-generated property can only be mapped to one of these\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs","lineNumber":841,"sourceCode":"                    break;\n                default:\n                    Check.DebugFail(\"Unexpected stored procedure type: \" + storeObjectIdentifier.StoreObjectType);\n                    break;\n            }\n        }\n\n        foreach (var resultColumn in sproc.ResultColumns)\n        {\n            if (resultColumn.PropertyName == null)\n            {\n                continue;\n            }\n\n            properties.Remove(resultColumn.PropertyName);\n\n            if (!storeGeneratedProperties.Remove(resultColumn.PropertyName))\n            {\n                throw new InvalidOperationException(\n                    RelationalStrings.StoredProcedureResultColumnParameterConflict(\n                        entityType.DisplayName(), resultColumn.PropertyName, storeObjectIdentifier.DisplayName()));\n            }\n        }\n\n        if (storeGeneratedProperties.Count > 0)\n        {\n            throw new InvalidOperationException(\n                RelationalStrings.StoredProcedureGeneratedPropertiesNotMapped(\n                    entityType.DisplayName(),\n                    storeObjectIdentifier.DisplayName(),\n                    storeGeneratedProperties.Values.Format()));\n        }\n\n        if (properties.Count > 0)\n        {\n            foreach (var property in properties.Values.ToList())\n            {","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/dotnet/efcore/blob/3a2006ef569de08368d59db5e1468aa8f407e4f8/src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs#L823-L859","documentation":"Thrown when a property is mapped to BOTH a result column and an output parameter of the same insert/update sproc (validator walks sproc.ResultColumns and tries to remove each result-column property from storeGeneratedProperties; if it was already consumed by an output parameter earlier, the set removal fails). A store-generated property may be read back through only one channel — result column OR output parameter, not both.","triggerScenarios":"On Insert/UpdateUsingStoredProcedure: .HasOutputParameter(p => p.Id) plus .HasResultColumn(p => p.Id) for the same property. Common when migrating from output parameters to result-set based sprocs without removing the old mapping.","commonSituations":"Switching a sproc from OUT parameter to SELECT-based return and leaving both calls in the fluent config; copy-paste of insert config to update config where one used OutputParameter and the other ResultColumn.","solutions":["Choose one read-back mechanism: drop .HasOutputParameter(p => p.Foo) and keep .HasResultColumn(p => p.Foo), or vice versa.","If the sproc genuinely returns both, split the property into two mapped properties — but that is rarely correct; instead align the sproc to return the value once."],"exampleFix":"// before\nentityType.InsertUsingStoredProcedure(\"InsertOrder\",\n    sp =>\n    {\n        sp.HasOutputParameter(o => o.OrderId);\n        sp.HasResultColumn(o => o.OrderId); // duplicate read-back\n    });\n\n// after\nentityType.InsertUsingStoredProcedure(\"InsertOrder\",\n    sp => sp.HasResultColumn(o => o.OrderId));","handlingStrategy":"validation","validationCode":"foreach (var et in model.GetEntityTypes())\n{\n    foreach (var sproc in new[] { et.GetInsertStoredProcedure(), et.GetUpdateStoredProcedure() })\n    {\n        if (sproc == null) continue;\n        var outputProps = sproc.Parameters\n            .Where(p => p.Direction != System.Data.ParameterDirection.Input && p.PropertyName != null)\n            .Select(p => p.PropertyName)\n            .ToHashSet();\n        foreach (var rc in sproc.ResultColumns.Where(c => c.PropertyName != null))\n        {\n            if (outputProps.Contains(rc.PropertyName))\n                Console.WriteLine($\"{et.Name}.{rc.PropertyName} on {sproc.Name} is both an output parameter and a result column.\");\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide per sproc whether to use output parameters OR result columns, then enforce it in code review.","When migrating between the two, search-and-remove the old mapping before adding the new one.","Document the chosen convention for each entity type."],"tags":["ef-core","stored-procedures","model-validation","store-generated"],"backgroundTag":null,"analyzedSha":"3a2006ef569de08368d59db5e1468aa8f407e4f8","analyzedAt":"2026-08-11T23:42:04.146Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}