Perfect, I found what happened. I changed edmx file properties to the following details and it was recongnized in container.registertype: 1- Code generation move to: Default 2- lazyloading : false and it worked. Additionally
paul hiles of unity.mvc3 responded:
"Most of the examples use DbContext as you say but there is nothing in Unity.Mvc3 that ties you to using Code First. For EF with edmx files, you will have an auto-generated ObjectContext implementation instead of a DbContext. This implements IDisposable
so needs to be treated in the same way as a DbContext. This means that you should register it with Unity using the HierarchicalLifetimeManager. e.g.
container.RegisterType<ObjectContext, MyDbEntities>( new HierarchicalLifetimeManager());"
brgds
Marked as answer by sebastianh on Mar 08, 2012 05:50 PM
sebastianh
Member
86 Points
40 Posts
Re: Unity IOC - Registering EF data context as a dependency
Mar 08, 2012 05:50 PM|LINK
Perfect, I found what happened. I changed edmx file properties to the following details and it was recongnized in container.registertype: 1- Code generation move to: Default 2- lazyloading : false and it worked. Additionally paul hiles of unity.mvc3 responded:
"Most of the examples use DbContext as you say but there is nothing in Unity.Mvc3 that ties you to using Code First. For EF with edmx files, you will have an auto-generated ObjectContext implementation instead of a DbContext. This implements IDisposable so needs to be treated in the same way as a DbContext. This means that you should register it with Unity using the HierarchicalLifetimeManager. e.g.
container.RegisterType<ObjectContext, MyDbEntities>( new HierarchicalLifetimeManager());"
brgds