0
votes

Im working with ASP.NET WebAPI & EntityFramework. I noticed that I could create API controller with VS template based one of my entities. The controller automatically has methods PUT, GET, POST, DELETE. Its very usefull and makes life easier.

But, the db connection initial in every single controller, I mean, every controller has DB connection object. (for example: ExampleEntities db = new ExampleEntities())

Is that the right way to work? Or should I create a BL or something to wrap the DB, and the controllers will access the db via BL?

tnx!

1
This is an extremely broad topic but - in a nutshell - that boilerplate is appropriate for simple applications. For your application, you should of course abstract and architect as you see fit. - Ant P

1 Answers

0
votes

You can use UOF + Repository + IoC architecture.