jeudi 9 mars 2017

Connection String Best Practice

When I create a new MVC project, using EF, and add a controller the beginning looks like this:

using //statement;
using //statement;
using //statement;
using //statement;

namespace ProjectName.Controllers
{
    public class TestController : Controller
    {
        private ConnectionStringName db = new ConnectionStringName(); // question here

Is this considered bad practice, since this same line is used in every new controller that I add? If so, what are the main reasons why this is frowned upon? What is a better way to implement this?

Any help/explanation is appreciated.

Aucun commentaire:

Enregistrer un commentaire