-
Notifications
You must be signed in to change notification settings - Fork 12
Home
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.
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.
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.
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"));
fixture.Customize(customization);
fixture.Create<Post>();