I am trying to make use of Unity Framework with Entity Framework. Let me explain the scenario. Let's say I have a Database with 5 tables. I will have 5 interfaces each of them corresponding to one table in Database having each field of table as a member. Now I want my Entity Framework generated classes to implement corresponding table interface. All navigational properties should return objects as interface references. This should allow me to resolve these entities using Unity framework to allow any one to extend EF(data) entities without breaking required codes. Is this possible?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
No there is no extensibility point for resolving entities with IoC container. EF will always handle instance creation of persisted entities. Morover EF mapping must work with classes not interfaces.
You can only handle
ObjectMaterialized
event onObjectContext
and provide some additional initialization of created entities.You can try to add interfaces by implementing custom T4 template and including some convention (like name of the interface is always I + name of the entity) but still without IoC.