Entity Framework Load () method does not load everything

I have a problem

I have a table with 44839 records

But when I try to load my table through EF with this code:

dbContext = new MyDbContext("MyContext"); dbContext.SalesRegister.Load(); BindingList<SalesRegister> db =dbContext.SalesRegister.Local.ToBindingList(); gridControl.DataSource = db; bsiRecordsCount.Caption = "RECORDS : " + db.Count; 

I get only 16311 entries

But when I use this, I get all my notes

 dbContext = new MyDbContext("MyContext"); List<SaleRegister> db = dbContext.SalesRegister.SqlQuery("select * from vwSalesRegister").ToList(); gridControl.DataSource = db; bsiRecordsCount.Caption = "RECORDS : " + db.Count; 

Why is this happening?

+5
source share
1 answer

And the solution for this was really simple! Be sure to define PK on both sides (code and database). Thanks @IvanStoev

+2
source

Source: https://habr.com/ru/post/1259188/


All Articles