Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i have following structure in DbContext class. Since i am new to Entity Framework i cant understand what is the purpose of each. Can anyone please explain it. This class is in DataAccess layer in the project



public class RegisterDb : DbContext
{
public RegisterDb () : base(ConfigurationManager.ConnectionStrings[RegisterDb].ConnectionString)
{
}

public RegisterDb (string connectionString) : base(connectionString)
{
}

public DbSet <student> Student { get; set; }



public virtual IDbSet<t> DbSet<t> () where T : class
{
return Set<t>();
}

public virtual void Commit()
{
base.SaveChanges();
}

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
Database.SetInitializer<registerdb>(null);
}
}

internal class Initialiser : DropCreateDatabaseAlways<registerdb>
{
protected override void Seed(RegisterDb context)
{
context.SaveChanges();
}
}
Posted
Updated 25-Jun-15 19:20pm
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900