title: Why does the call to ObjectSet<T>.AddObject() get all entities of type T?
body: <pre><code>var he = new LogHistoryEntry
               {
                   ActionId = action.Id,
                   ObjectId = logObject.Id,
                   UserId = user.Id,
                   Info = msg,
                   Item = s.Id,
                   Date = DateTime.Now
               };
  
  ctx.LogHistoryEntries.AddObject(he);
  </code></pre>
  
  <p>I just want to add one log entry. I don't want EF to read all the entries already persisted in db.
  How can I avoid this?</p>
  
  <p>UPDATE1:</p>
  
  <p>Well, I would not call it a solution but this approach works.</p>
  
  <pre><code>public static void LogChanges(ObjectContext context, string msg, int itemId, int userId, int logActionId, int logObjectId)
  {
      context.ExecuteStoreCommand(
                  "insert into log_history (object_id,action_id,item,info,user_id,date) values ({0},{1},{2},{3},{4},GETDATE())",
                  logObjectId, logActionId, itemId, msg, userId);
  }
  </code></pre>
  
  <p>Yet, I don't like this, cause it's a hack from the point of view of layers separation.
  Here I'm to know storage column names. That's not OK.</p>
  
  <p>UPDATE2:</p>
  
  <p>This is what sql-profiler rturn upon AddObject call:</p>
  
  <blockquote>
    <p>exec sp_executesql N'SELECT  [Extent1].[id] AS [id], 
    [Extent1].[object_id] AS [object_id],  [Extent1].[action_id] AS
    [action_id],  [Extent1].[item] AS [item],  [Extent1].[info] AS [info],
    [Extent1].[date] AS [date],  [Extent1].[user_id] AS [user_id] FROM
    [dbo].[log_history] AS [Extent1] WHERE [Extent1].[user_id] =
    @EntityKeyValue1',N'@EntityKeyValue1 int',@EntityKeyValue1=4</p>
  </blockquote>
  
  <p>Sure, it asks not for all log entreis but why it makes a check for a given user id is a mystery for me.</p>