title: Error CS0411 - EF 6, DotNet core 6, Ms SQLServer
body: <p>My scenario
  Visual Studio 2022, Blazor WebApplication + ASPnet hosted (so 3 projects in my solution), SQL Server with existing DB (used by other apps).</p>
  <p>TabUser has a FK with TabUserRoles (1 -&gt; many)</p>
  <p>so i try to scaffold db to create models for my entities. I use CMD with command</p>
  <pre><code>dotnet ef dbcontext scaffold &quot;connectionstring&quot; Microsoft.EntityFrameworkCore.SqlServer -o Models
  </code></pre>
  <p>everything works fine but... when I compile i receive a couple of <strong>CS0411</strong> errors for my tables</p>
  <pre><code>  entity.HasOne()   //entity is TabUserRoles
        .WithMany()
         .HasForeignKey(d =&gt; d.IdUser)
          HasConstraintName(&quot;Fk_UserRole_Users&quot;);
  </code></pre>
  <p>I can fix them by writing an explicit type</p>
  <pre><code>  entity.HasOne&lt;TabUserRole&gt;()                //&lt;====== another Table/DBSet
        .WithMany()
         .HasForeignKey(d =&gt; d.IdUser)
          HasConstraintName(&quot;Fk_UserRole_Users&quot;);
  </code></pre>
  <p>this compiles successfully but when I try to retrieve data from TabUsers with</p>
  <pre><code>_context.TabUsers.ToList();  //error happens HERE
  </code></pre>
  <p>Error 500 from my Blazor server, developer tools console is</p>
  <pre><code>1 .Failed to load resource: net::ERR_CONNECTION_REFUSED
  
  2. api/user:1          Failed to load resource: the server responded with a status of 500 ()
  blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
        Unhandled exception rendering component: Response status code does not indicate success: 500 (Internal Server Error).
  System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
     at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
     at System.Net.Http.Json.HttpClientJsonExtensions.&lt;GetFromJsonAsyncCore&gt;d__13`1[[CAPhotoManager.Shared.ServiceResponse`1[[System.Collections.Generic.List`1[[CAPhotoManager.Shared.Model.TabUser, CAPhotoManager.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], CAPhotoManager.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
     at CAPhotoManager.Client.Services.UserService.GetUsers() in C:\Progetti\net\CAPhotoManager\CAPhotoManager\Client\Services\UserService.cs:line 17
     at CAPhotoManager.Client.Pages.Users.OnInitializedAsync() in C:\Progetti\net\CAPhotoManager\CAPhotoManager\Client\Pages\Users.razor:line 25
     at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
     at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
  </code></pre>