title: Entity Framework - refresh objects from database
body: <p>I'm having trouble with refreshing objects in my database. I have an two PC's and two applications.</p>
  
  <p>On the first PC, there's an application which communicates with my database and adds some data to Measurements table.
  On my other PC, there's an application which retrives the latest Measurement under a timer, so it should retrive measurements added by the application on my first PC too. </p>
  
  <p>The problem is it doesn't. On my application start, it caches all the data from database and never get new data added. I use Refresh() method which works well when I change any of the cached data, but it doesn't refresh newly added data.</p>
  
  <p>Here is my method which should update the data:</p>
  
  <pre><code>    public static Entities myEntities = new Entities();
  
      public static Measurement GetLastMeasurement(int conditionId)
      {
          myEntities.Refresh(RefreshMode.StoreWins, myEntities.Measurements);
  
          return (from measurement in myEntities.Measurements
                  where measurement.ConditionId == conditionId
                  select measurement).OrderByDescending(cd =&gt; cd.Timestamp).First();
      }
  </code></pre>
  
  <p>P.S.
  Applications have different connection strings in app.config (different accounts for the same DB).</p>