EntityFramework.Utilities icon indicating copy to clipboard operation
EntityFramework.Utilities copied to clipboard

Error in MappingHelper when IsHierarchyMapping=true, but no Conditions

Open jongerik opened this issue 9 years ago • 2 comments

I'm using the utility on EF 6.1.3 and Model First. In the function EfMapping(DbContext db) if (mapping.EntityTypeMappings.Any(m => m.IsHierarchyMapping)) is true But
var withConditions = mapping.EntityTypeMappings.Where(m => m.Fragments[0].Conditions.Any()).ToList(); is empty. So the next step crashes on ColumnName = .... tableMapping.TPHConfiguration = new TPHConfiguration { ColumnName = withConditions.First().Fragments[0].Conditions[0].Column.Name, Mappings = new Dictionary<Type, string>() }; I resolved this by adding the following before this

                if (withConditions.Any())
                {

I don't know the couse of the empty list. We don't use TPH, Just normal ForeighnKey relation.

jongerik avatar Oct 02 '15 09:10 jongerik

The same error

NikolayEm avatar Feb 23 '16 13:02 NikolayEm

The same error!

rhgs avatar Jul 04 '17 19:07 rhgs