I am using Entity Framework 6.1.3.
When I try to get the values ββfrom the database table, it returns me 0 elements, but in the database - 9 rows.
And Entity FrameWork calls the OnModelCreating method.
I searched the entire Internet but found nothing to fix it.
My DbContext Class
namespace TestTask.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class Entities : DbContext
{
public Entities()
: base("MenuItemsContainer")
{ }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Properties()
.Where(p => p.Name == "Id")
.Configure(p => p.IsKey());
}
public virtual DbSet<DataMenuItemSet> DataMenuItemSet { get; set; }
public virtual DbSet<ItemsSet> ItemsSet { get; set; }
}
}
My DataMenuItemSet Class
using System.ComponentModel.DataAnnotations;
namespace TestTask.Models
{
using System;
using System.Collections.Generic;
public partial class DataMenuItemSet
{
public DataMenuItemSet()
{
this.ItemsSet = new HashSet<ItemsSet>();
}
[Key]
public int Id { get; set; }
public bool IsRoot { get; set; }
public string Name { get; set; }
public Nullable<int> Parent { get; set; }
public virtual ICollection<ItemsSet> ItemsSet { get; set; }
}
}
All this is created using the Entity Framework.
I need to get values ββfrom a database.
Update
I solved the problem.
, . , , -, ConsoleApplication, . db dbcontext , , . , -, edmx dbcontext, , .

- ConsoleApplication
- - dbcontext

Web.config
Web.config App.cofig ConsoleApplication .

ConsoleApplication .
, .
!!!