So, I never did and I have no idea, in an asp.net mvc project, how should I proceed with this?
If you have not yet developed a project in Asp.net MVC this one introduces the concept and have some references to help you.
... if I use Controller's and View's generated using scaffold, where they directly use my initial context in Mysql ...
Using your context directly you will be tied to technology, because everywhere in the code where you have reference to this technology you would need to change. Depending on your implementation it is a very hard rework, as well as running a risk of code duplication and having more difficulty testing your application.
Exemplo:
Using NHibernate to retrieve data in the Controller , I would have references like NHibernate , NHibernate.Linq , in addition to objects specific to NHibernate technology such as ISession , etc.
using System;
using System.Web.Mvc;
using NHibernate; //Código relacionado a tecnologia de acesso a BD
using NHibernate.Linq; //Código relacionado a tecnologia de acesso a BD
using System.Linq;
using NhibernateMVC.Models;
namespace NhibernateMVC.Controllers
{
public class ExemploController : Controller
{
public ActionResult Index()
{
//Você provavelmente iria duplicar código como esse em outros Controllers
//gerando possíveis retrabalhos
using (ISession session = NHibertnateSession.OpenSession())
{
var empregados = session.Query<Empregado>().ToList();
return View(empregados);
}
}
}
}
An alternative is to use the Repository project pattern , it centralizes your access code to the database (insert, update, delete and data recovery) by adding a separation layer so that by changing data access technology you only change one layer of your application with a very small rework compared to the issue of directly using the context.
Given the example, by using specific data access technologies directly in your Controllers , be it Entity Framework, MySql, X, Y, etc ... you would get references and codes that generate rework if you change the technology.
In short, instead of creating an ASP.NET MVC project and developing your application, it would be interesting to create at least one more project in your solution to centralize your database access code by isolating domain objects ( related to the business) of access code details.