private static FieldInfo TryMatchFieldName(IConventionModel model, Type entityClrType, Type propertyType, string propertyName) { IReadOnlyDictionary <string, FieldInfo> fields; var entityType = model.FindEntityType(entityClrType); if (entityType == null) { var newFields = new Dictionary <string, FieldInfo>(StringComparer.Ordinal); foreach (var field in entityClrType.GetRuntimeFields()) { if (!field.IsStatic && !newFields.ContainsKey(field.Name)) { newFields[field.Name] = field; } } fields = newFields; } else { fields = entityType.GetRuntimeFields(); } var sortedFields = fields.OrderBy(p => p.Key, StringComparer.Ordinal).ToArray(); var typeInfo = propertyType.GetTypeInfo(); var match = TryMatch(sortedFields, "<", propertyName, ">k__BackingField", null, null, entityClrType, propertyName); if (match == null) { match = TryMatch(sortedFields, propertyName, "", "", typeInfo, null, entityClrType, propertyName); var camelPrefix = char.ToLowerInvariant(propertyName[0]).ToString(); var camelizedSuffix = propertyName.Substring(1); match = TryMatch(sortedFields, camelPrefix, camelizedSuffix, "", typeInfo, match, entityClrType, propertyName); match = TryMatch(sortedFields, "_", camelPrefix, camelizedSuffix, typeInfo, match, entityClrType, propertyName); match = TryMatch(sortedFields, "_", "", propertyName, typeInfo, match, entityClrType, propertyName); match = TryMatch(sortedFields, "m_", camelPrefix, camelizedSuffix, typeInfo, match, entityClrType, propertyName); match = TryMatch(sortedFields, "m_", "", propertyName, typeInfo, match, entityClrType, propertyName); } return(match); }