title: Entity Framework avoid LazyLoading / already open DataReader issue
body: <p>With an Union Query which runs several times successively I get <code>UserlistSection</code> objects for each alphabetic letter, if <code>Users</code> exist with the starting letter.
  So I get something like this:</p>
  
  <ul>
  <li>UserlistSection "A"
  
  <ul>
  <li>User</li>
  <li>User</li>
  </ul></li>
  <li>UserlistSection "H"
  
  <ul>
  <li>User</li>
  </ul></li>
  <li>UserlistSection "Y"
  
  <ul>
  <li>User</li>
  <li>User</li>
  <li>User</li>
  </ul></li>
  </ul>
  
  <p>But the query throws following exception</p>
  
  <pre><code>MySql.Data.MySqlClient.MySqlException: There is already an open DataReader associated with this Connection which must be closed first.
  </code></pre>
  
  <p>The query Task</p>
  
  <pre><code>public UserRepository(myDatabase database)
      {
          _database = database;
      }
  
  public Task&lt;ObservableCollection&lt;User&gt;&gt; GetUserFriendsAsync(int id, string letter)
      {
          return Task.Factory.StartNew(() =&gt;
          {
              try
              {
                  var query1 = (from urs in _database.user_relationships
                                join u in _database.users on urs.relationship_user_from equals u.user_id
                                where urs.relationship_user_to == id
                                      &amp;&amp; u.user_name.StartsWith(letter)
                                      &amp;&amp; urs.relationship_status == 1
                                select new User
                                {
                                    Id = u.user_id,
                                    Username = u.user_name,
                                    AvatarByte = u.user_avatar,
                                    Gender = u.user_gender,
                                    GroupId = u.user_usergroup,
                                    LoginStatusId = u.user_loginstatus
                                });
  
                  var query2 = (from urs in _database.user_relationships
                                join u in _database.users on urs.relationship_user_to equals u.user_id
                                where urs.relationship_user_from == id
                                      &amp;&amp; u.user_name.StartsWith(letter)
                                      &amp;&amp; urs.relationship_status == 1
                                select new User
                                {
                                    Id = u.user_id,
                                    Username = u.user_name,
                                    AvatarByte = u.user_avatar,
                                    Gender = u.user_gender,
                                    GroupId = u.user_usergroup,
                                    LoginStatusId = u.user_loginstatus
                                });
  
                  // Union to get users via relationships (from - to and to - from)
                  var queryUnion = query1.Union(query2).OrderBy(u =&gt; u.Username);
  
                  return new ObservableCollection&lt;User&gt;(queryUnion);
              }
              catch (Exception ex)
              {
                  Trace.WriteLine("UserRepository - GetUserFriendsAsync" + ex);
                  return null;
              }
          });
      }
  </code></pre>
  
  <p>And my Object / Method to create the Collection</p>
  
  <pre><code>public class UserlistSection : ObservableObject
  {
      #region Attributes
  
      private string _letter;
      private ObservableCollection&lt;User&gt; _users;
  
      #endregion Attributes
  
      public string Letter
      {
          get { return _letter; }
          set { Set(ref _letter, value); }
      }
  
      public ObservableCollection&lt;User&gt; Users
      {
          get { return _users; }
          set { Set(ref _users, value); }
      }
  }
  
  // -------------------------------------------------------------------------
  
   public async void UpdateFriendlistCollection()
      {
          IsLoading = true;
          Friendlist = new ObservableCollection&lt;UserlistSection&gt;();
  
          for (var c = 'A'; c &lt;= 'Z'; c++)
          {
              try
              {
                  var letter = c.ToString();
                  var userCollection = await _userRepository.GetUserFriendsAsync(_userObj.Id, letter);
  
                  if (userCollection.Count &lt; 1) return;
  
                  foreach (var friend in userCollection)
                  {
                      friend.AvatarImage = friend.GetAvatarImgByPixel(200);
                  }
  
                  var section = new UserlistSection
                  {
                      Letter = letter,
                      Users = userCollection
                  };
  
                  Friendlist.Add(section);
              }
              catch (Exception ex)
              {
                  Trace.WriteLine("FriendlistViewModel - UpdateFriendlistCollection: " + ex.Message);
              }
          }
  
          IsLoading = false;
      }
  </code></pre>
  
  <p>There are probably better ways to build the query, but I couldn't figure out how yet. So would be nice if someone can see my mistakes to avoid the LazyLoading / solve the exception.</p>
  
  <p>If I'm missing some explanation, please just tell.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>When I add <code>MultipleActiveResultSets=True</code> like that, it tells me that the keyword isn't support?</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name="someDatabase"   connectionString="metadata=res://*/Repository.Database.SomeDatabase.csdl|res://*/Repository.Database.SomeDatabase.ssdl|res://*/Repository.Database.SomeDatabase.msl;provider=MySql.Data.MySqlClient;provider connection string=&amp;quot;server=127.0.0.1;user id=someUser;persistsecurityinfo=True;password=somePassword;multipleactiveresultsets=True;database=someDatabase;&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>System.ArgumentException: Keyword not supported.
  Parametername: multipleactiveresultsets
  bei MySql.Data.MySqlClient.MySqlConnectionStringBuilder.GetOption(String key)
  bei MySql.Data.MySqlClient.MySqlConnectionStringBuilder.set_Item(String  keyword, Object value)
  </code></pre>