Unable to find any child-parent relationship for the child type
Hi Tanks for the coolio package
Unable to find any child-parent relationship for the child type analyzing the navigation property 'Users' on the parent entity.
What to do when i don't want the child items, i just want the parent flat without relationships?
THis doesn't seam to be working:
await db.GetAsync(new Foo { Id = id }, options => { options.WithEntityMappingOverride(OrmConfiguration.GetDefaultEntityMapping<Foo>().Clone().RemoveAllRelationships().RemoveProperty(x => x.Bar)); });
The original migration / model is from EF Core many to many.
Unable to find any child-parent relationship for the child type 'Bar' and the parent 'USer' when analyzing the navigation property 'Users' on the parent entity.
even tried with .RemoveParentChildRelationship(x => x.Bar), RemoveParentChildrenRelationship(x => x.Bar), .RemoveChildParentRelationship(x => x.Bar),
I am getting this error as well, using fluent registration. Here is a simple example to duplicate the issue:
public class Parent {
public long Key { get; set; }
public IEnumerable<Child> Children { get; set; }
}
public class Child {
public long Key { get; set; }
public long ParentKey { get; set; }
public Parent Parent { get; set; }
}
public class Config {
private static void ConfigureParentsAndChildren() {
OrmConfiguration.GetDefaultEntityMapping<Parent>()
.SetDialect(SqlDialect.MySql)
.SetTableName("parents")
.SetProperty(p => p.Key, p => p
.SetDatabaseColumnName("parent_id")
.SetPrimaryKey()
.SetDatabaseGenerated(DatabaseGeneratedOption.Identity))
.SetParentChildrenRelationship( //<-------- FAILS
p => p.Children,
c => c.Parent
);
OrmConfiguration.GetDefaultEntityMapping<Child>()
.SetDialect(SqlDialect.MySql)
.SetTableName("children")
.SetProperty(p => p.Key, p => p
.SetDatabaseColumnName("child_id")
.SetPrimaryKey()
.SetDatabaseGenerated(DatabaseGeneratedOption.Identity))
.SetChildParentRelationship(
c => c.Parent,
c => c.ParentKey
);
}
}
Is this supposed to work the way I've written it?
In my example above, if I change it to use .RegisterEntity<T>() instead of .GetDefaultEntityMapping<T>(), it runs.
In my example above, if I change it to use .RegisterEntity() instead of .GetDefaultEntityMapping(), it runs.
RegisterEntity should be the right way when performing fluent registrations from scratch, as GetDefaultEntityMapping will make inferations that need to be overridden. Let me know if you do encounter any more problems in this area.