By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,899 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,899 IT Pros & Developers. It's quick & easy.

Entity Framwork repeats the same results

P: 29
Hi
I have used Linq to SQL for a long time, but now, because I need to work with MySQL I had to start with Entity FrameWork.
I combine ADO.NET and EF and I did not realize about this issue, but recently, I had found a very big problem that it`s driving me crazy.

A simple query...

Dim Query = (From p in db.products select p).ToList

It gives the results the first time good, but when I run this query again, it gives the SAME RESULTS again and again !!!

I mean, any change in the database it is not reflected in that query. The only way is to quit program and run again.

Visual Basic - VS2013
Entity Framework 5.0 (MySql)

Thanks.
Nov 11 '15 #1
Share this Question
Share on Google+
2 Replies


Ammarhassan48
P: 3
There might some mistake in your logic . Can you show the piece of code that is not working ?
Nov 12 '15 #2

P: 29
Hi
The mystery has been solved:

EF caches the database. So, it is very important to make a context when needed and then dispose it.

Expand|Select|Wrap|Line Numbers
  1. Using DBEntity As New DBEntityModel()
  2.    ....
  3.     ....
  4. End Using
  5.  
Thanks!
Nov 12 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.