dbroudy / LazyEntityGraph

LazyEntityGraph is an open source library for .NET which lets you generate object graphs with circular dependencies, such as those found in ORMs, by lazily generating relationship properties.
MIT License
27 stars 12 forks source link

Support one sided navigation properties #29

Closed christophano closed 3 years ago

christophano commented 3 years ago

Hi, I'm having a problem with my model, which makes use of one sided navigation properties, which doesn't seem to be supported. For example;

class Foo
{
    public int Id { get; set; }
    public int BarId { get; set; }
    public virtual Bar Bar { get; set; }
}
class Bar
{
    public int Id { get; set; }
}
class Context : DbContext
{
    void OnModelCreating(ModelBuilder builder)
    {
        builder.Entity<Foo>()
               .HasOne(f => f.Bar)
               .WithMany()
               .HasForeignKey(f => f.BarId);
    }
}

I have added support for this, if you accept pull requests.

dbroudy commented 3 years ago

Thanks for the PR @christophano I'll take a look at it this weekend.