Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Load() method doesn't 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 only get 16311 records

But when I use this I get all my records

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??

like image 760
Rafael Córdova Avatar asked Oct 29 '22 17:10

Rafael Córdova


1 Answers

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

like image 145
Rafael Córdova Avatar answered Nov 15 '22 04:11

Rafael Córdova