user3514987
user3514987

Reputation: 220

Web API ASP.NET Dependency injection

I've started looking into Web API 2.2. I understand the concepts and the purpose of this framework.

I was having some issues with Dependency Injection yesterday and found a resolution to the problem.

My question is, do I really need to create a interface for all my classes? I would have to create so many interfaces.

I am using Entity framework and there is a lot of tables. I find it very hard to believe that I really need to create an interface for each table in order to perfrom CRUD operations.

Isn't there any generic way to register dependency objects?

The issue is also I have a lot of classes that is not related to each other and in the dependency graph I would have to register these two.

Thanks!

Upvotes: 1

Views: 115

Answers (1)

Vagelis Ouranos
Vagelis Ouranos

Reputation: 482

You definitely should NOT create interfaces for your domain model. Interfaces should be created for things like repositories or services to be injected in each web api controller.

Edit You should create a repository interface for each aggregate root. What's an Aggregate Root?

Upvotes: 2

Related Questions