Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am using Entity Framework's DbContext to load data into an Entity Collection from Database.
Here is the code that I am using, it has data in Table two rows are there but still not loading. Can anybody please help me in this regards where am I missing this

C#
public class DAL : DbContext
{
    public DAL() : base("TestConnectionString") { }
 
    public DbSet<Employee> employees { get; set; }
 
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        //base.OnModelCreating(modelBuilder);
        modelBuilder.Entity<Employee>().ToTable("EmployeeTable");
        modelBuilder.Entity<Employee>().HasKey(x => x.Id);
    }
}


TestConnectionString us fine, but I am confused with the DbSet etc, I am not able to understand that part. I did not create Edmx file for this, but just using this way as it is shown in a tutorial can anybody please help me, this is not running and showing me the data I wanted in my View.

What I have tried:

Coding and searching in google and asking friends.
Posted

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