title: How do I make data calls from different Blazor components simultaneously?
body: <p>I'm new to Blazor and trying to make a page with several separate components to handle a massive form. Each individual component covers a part of the form.</p>
  <p>The problem I'm facing is that each of my components needs access to data from the back-end, and not every component uses the same data. When the page loads, each components makes an attempt to fetch data from the server, which causes a problem with Entity Framework.</p>
  <blockquote>
  <p>A second operation started on this context before a previous operation
  completed. This is usually caused by different threads using the same
  instance of DbContext.</p>
  </blockquote>
  <p>This is obviously caused by the fact that my components are initialized at the same time, and all make their attempt to load the data simultaneously. I was under the impression that the way DI is set up in Blazor, this wouldn't be a problem, but it is.</p>
  <p>Here are the components in my template:</p>
  <pre><code>&lt;CascadingValue Value=&quot;this&quot;&gt;
      &lt;!-- BASE DATA --&gt;
      &lt;CharacterBaseDataView /&gt;
  
      &lt;!-- SPECIAL RULES --&gt;
      &lt;CharacterSpecialRulesView /&gt;
  &lt;/CascadingValue&gt;
  </code></pre>
  <p>Here is how my components are initialized:</p>
  <pre class="lang-cs prettyprint-override"><code>protected async override Task OnInitializedAsync()
  {
      CharacterDetailsContext = new EditContext(PlayerCharacter);
      await LoadCharacterAsync();
  }
  
  private async Task LoadCharacterAsync()
  {
      PlayerCharacter = await PlayerCharacterService.GetPlayerCharacterAsync(ViewBase.CharacterId.Value);
      CharacterDetailsContext = new EditContext(PlayerCharacter);
  }
  </code></pre>
  <p>When two components with the above code are in the same view, the mentioned error occurs. I thread using the synchronous version &quot;OnInitialized()&quot; and simply discarding the task, but that didn't fix the error.</p>
  <p>Is there some other way to call the data so that this issue doesn't occur? Or am I going about this the wrong way?</p>