{"record":{"id":"e878bbb171ab7d20","repo":"aspnetboilerplate/aspnetboilerplate","slug":"the-property-propertyinfo-name-was-not-found-in","errorCode":null,"errorMessage":"The property {propertyInfo.Name} was not found in {mainMap.EntityType.Name} entity","messagePattern":"The property (.+?) was not found in (.+?) entity","errorType":"exception","errorClass":"KeyNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Abp.Dapper/Dapper-Extensions/Sql/SqlGenerator.cs","lineNumber":331,"sourceCode":"        var sql = new StringBuilder($\"DELETE FROM {GetTableName(classMap)}\");\n        sql.Append(\" WHERE \").Append(predicate.GetSql(this, parameters, true));\n        return sql.ToString();\n    }\n\n    public virtual string IdentitySql(IClassMapper classMap)\n    {\n        return Configuration.Dialect.GetIdentitySql(GetTableName(classMap));\n    }\n\n    public virtual string GetReferenceKey(IMemberMap map)\n    {\n        return $\"{map.ClassMapper.TableName}.{map.ColumnName}\";\n    }\n\n    private static IMemberMap GetPropertyMap(IClassMapper mainMap, MemberInfo propertyInfo)\n    {\n        if (!mainMap.Properties.Any(p => p.MemberInfo == propertyInfo))\n            throw new KeyNotFoundException($\"The property {propertyInfo.Name} was not found in {mainMap.EntityType.Name} entity\");\n        return mainMap\n            .Properties\n            .Where(p => p.MemberInfo == propertyInfo)\n            .Select(propertyMap => propertyMap)\n            .Single();\n    }\n\n    private string GetJointTables(IClassMapper mainMap, Table table, IDictionary<string, object> parameters, IList<IReferenceMap> includedProperties = null)\n    {\n        if (parameters == null)\n        {\n            throw new ArgumentNullException(nameof(parameters), $\"{nameof(parameters)} cannot be null.\");\n        }\n\n        var result = new StringBuilder();\n        var joins = new StringBuilder();\n        var sql = new StringBuilder();\n        var parent = Tables.Single(t => t.Identity == table.ParentIdentity);","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/aspnetboilerplate/aspnetboilerplate/blob/2323c13a152aa0ebfb37af3830f687d7f5b53795/src/Abp.Dapper/Dapper-Extensions/Sql/SqlGenerator.cs#L313-L349","documentation":"GetPropertyMap throws KeyNotFoundException when the supplied MemberInfo is not among the properties mapped on the main entity's ClassMapper. It is used while resolving left/right property maps for reference (join) mappings, so a property that participates in a reference but isn't mapped on the entity triggers this.","triggerScenarios":"Building a reference mapping where the referenced property name/MemberInfo belongs to a different entity, or the property is not registered in the ClassMapper (e.g. it's Ignore()d or auto-mapping skipped it).","commonSituations":"Typo or renamed property in a reference configuration; property excluded by MapConvention (private, no setter) but still referenced in a join config; mapping definitions stale after entity refactoring.","solutions":["Add the missing property to the entity's ClassMapper (ensure it is mapped, not Ignored)","Verify the MemberInfo/name used in the reference configuration belongs to mainMap.EntityType","Check auto-mapping conventions (accessibility, get/set) so the property is discovered","Rebuild mappings if a cached map predates an entity change"],"exampleFix":"// before\nMap(x => x.CustomerId).Ignore(); // not mapped\n// reference config references x => x.CustomerId -> throws\n// after\nMap(x => x.CustomerId); // mapped, resolvable in reference config","handlingStrategy":"validation","validationCode":"bool mapped = mainMap.Properties.Any(p => p.MemberInfo == propertyInfo);\nif (!mapped) throw new InvalidOperationException($\"{propertyInfo.Name} is not mapped on {mainMap.EntityType.Name}\");","typeGuard":"bool IsMappedOn(IClassMapper map, MemberInfo mi) => map?.Properties?.Any(p => p.MemberInfo == mi) == true;","tryCatchPattern":"try { BuildReferenceSql(...); } catch (KeyNotFoundException ex) when (ex.Message.Contains(\"was not found in\")) { throw new MappingException(\"Reference configuration points to an unmapped property\", ex); }","preventionTips":["Keep every property used in reference/join configs mapped in the ClassMapper","After renaming entity properties, update reference configurations and re-run mapping tests","Avoid Ignoring properties that participate in joins"],"tags":["csharp","mapping","dapper","reflection"],"backgroundTag":"entity-not-found","analyzedSha":"2323c13a152aa0ebfb37af3830f687d7f5b53795","analyzedAt":"2026-09-08T08:00:50.638Z","contentChangedAt":"2026-09-08T08:00:50.638Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}