Is it better to use ADO.NET or EF to manipulate database objects from MVC? [closed]

1

I currently use the Entity Framework to make database connections from C # with MVC, but I find it rather tedious to be adding the tables and everything to the database model in the project, and if something is modified I have to delete and re-add in the case of the complex of procedures or functions.

Now I started using SqlConnection and executed the query or procedure directly.

The question is what would be the most appropriate way to do it in terms of performance? and, what is the right thing or should it be?

Entity Framework:

 bdEntities db = new bdEntities();
 var list = (from ex in db.Usuario.AsEnumerable()
                select new
                {   id_usuario = ex.UsuarioID,
                    s_Nombre= ex.Nombre,

                }).ToList();

ADO.NET:

String conexion = ("Data Source=Server;Initial Catalog=master;User ID=Username;Password=P4ssw0rD");
SqlConnection cnn = new SqlConnection(conexion);
cnn.Open();
string var1, var2;
String consulta = "select Nombre, * from BD..usuario";
SqlCommand cmd = new SqlCommand(consulta, cnn);
SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())
{
    var1 = dr["UsuarioID"].ToString();
    var2 = dr["Nombre"].ToString();
}
    
asked by Richard 01.06.2018 в 00:35
source

0 answers