Skip to content
Alex Fox Gill edited this page Jun 8, 2016 · 8 revisions

This wiki contains documentation for using LazyEntityGraph. See the sidebar on the right for more in-depth coverage.

Quick Start

Currently, this project only offers out-of-the-box integration with AutoFixture and Entity Framework, so here's an example of how to get up and running with this setup.

1. Add project references

For integration with AutoFixture, grab the LazyEntityGraph.AutoFixture package. We'll also need the LazyEntityGraph.EntityFramework package if we want to automatically wire up relationships between entities. You can install both of these via NuGet.

2. Create AutoFixture customization

Using a Code First DbContext (nb: Code-First contexts must have a constructor with one string argument which calls base(nameOrConnectionString)):

var customization = new LazyEntityGraphCustomization(
    ModelMetadataGenerator.LoadFromCodeFirstContext(str => new BlogContext(str), true));

Using an EDMX file:

var customization = new LazyEntityGraphCustomization(
    ModelMetadataGenerator.LoadFromEdmxContext<BlogContext>("Blog"));

3. Add the customization to our Fixture:

fixture.Customize(customization);

4. Generate some objects!

fixture.Create<Post>();