3
What is the difference between creating a Context with Dbcontext and Datacontext? Is there any difference in performance or best practice between one or the other?
See the examples below;
namespace _DBContext.DBase.Banco
{
public class dbContext : using System.Data.Entity.DbContext
{
public dbContext()
: base("EntityConn")
{
Database.SetInitializer<dbContext>(null);
}
public DbSet<Tabela_DocsIten> Tabela_DocsIten { get; set; }
}
}
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="MeuBD")]
public partial class ModeloColDataContext : System.Data.Linq.DataContext
{
public System.Data.Linq.Table<Tabela_DocsIten> Tabela_DocsItens
{
get
{
return this.GetTable<Tabela_DocsIten>();
}
}
}
Then it is better to use Datacontext than to use Dbcontxt ?
– Marco Souza
@Gokussjgod, it depends. No one can definitely say that one is better than the other, because it depends on your project, questions like: "What is the size/budget of your project? How many developers will work on it?" should be taken into account. I left in the reply, what is written in the documentation =)
– Taisbevalle
Very interesting your last reference.
– Marco Souza