0

I'm trying to implement some kind of IoC on an ASP.NET MVC 3 project (built with Entity Framework for data access) by using Unity. Entities are being converted to custom objects that implement a common interface. Those custom objects are used by the controller who puts them in a "view model" and forward it to the view.

I'm following some guides but I can't find out how to configure Unity so that the right object is mapped for every controller.

Can someone point me to a good guide/tutorial/how-to? Hope I have clearly explained the problem... I have never used Unity, so forgive me if that's a dumb/noobish question.

Thanks in advance,

Daniele Salatti

8
  • Do you just want to inject repository into your controller, or do you want more than that? Commented Sep 14, 2011 at 9:21
  • In general you shouldn't abstract away your domain layer (entities). Instead of implementing interfaces on your entities, make them POCOs. This prevents you from having to put an abstraction on top of them. Commented Sep 15, 2011 at 7:03
  • @Steven: going to read something about that... I don't know POCO. Commented Sep 15, 2011 at 12:37
  • Sorry, is the repository the only think you want to inject? Or do you want to inject you entites / domain model objects as well? Commented Sep 15, 2011 at 12:51
  • @Daniele: Just Google "Entity Framework POCO" Commented Sep 15, 2011 at 13:03

1 Answer 1

1

Check this post it explain how to implement Repository Pattern for EntityFrameWork

http://www.codeproject.com/KB/database/ImplRepositoryPatternEF.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.