0

I am using ADO.NET Mocking Context Generator plugin for my Entity Framework model. I have not started on using mocks yet, just trying to fix generated entity and context classes to make application run as before without exceptions. I've already fixed T4 template to support SaveChanges method.

Now I've got another problem: when I try to access any navigation property it is set to null. All the primitive fields inherited from DB table are set and correct.

So what I am doing is the following

using (var context = MyContext())
{
      var order = context.Orders.Where(p => p.Id == 7);
      var product = order.Products;
}

in this case product is set to null. But that was not a case while using default code generator, it used to return real product object.

Thanks ahead for any suggestions!

olenak
  • 179
  • 1
  • 6

1 Answers1

0

I tried to fix t4 template and nothing helped. So I gave up on ADO.NET Mocking Context Generator template and switched to ADO.NET POCO Entity Generator template. I followed the steps mentioned here http://slappyza.wordpress.com/2010/08/08/getting-the-entity-framework-to-generate-an-interface-for-mocking/ But instead of RhinoMock for testing I used Moq library.

And it finally worked!

olenak
  • 179
  • 1
  • 6