title: Entity Framework | Sequence contains more than one matching element
body: <p>I used the database first approach.
  The model is right (or at least it looks like)
  But I always get this error. Please, I've already tried so many things..
  The full code of my program (and even sql script by which I create my database)
  is here: <a href="https://github.com/AntonioParroni/test-task-for-backend-stack/blob/main/Server/Models/ApplicationContext.cs" rel="noreferrer">https://github.com/AntonioParroni/test-task-for-backend-stack/blob/main/Server/Models/ApplicationContext.cs</a></p>
  <p>Since I have a mac. I created my model with dotnet ef cli commands (dbcontext scaffold)
  I can use my context. But I can't touch any DbSet..</p>
  <pre><code>public static void Main(string[] args)
      {
          using (ApplicationContext context = new ApplicationContext())
          {
              Console.WriteLine(context.Database.CanConnect());
              var months = context.Months.ToList();
              foreach (var month in months)
              {
                  Console.WriteLine(month.MonthName);
              }
          }
          //CreateHostBuilder(args).Build().Run();
      }
  </code></pre>
  <p>It is not my first time using EF. And everything was working fine before, in many simple projects or tasks. While here.... It doesn't matter what I do (I even tried to rename all of my columns name, erase all tables except one, modify the context code, use the same steps from this project on a new, totally empty project..)
  It is always..</p>
  <pre><code>Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor' threw an exception.
   ---&gt; System.TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
       ---&gt; System.InvalidOperationException: Sequence contains more than one matching element
         at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException() in System.Linq.dll:token 0x600041c+0xa
  ect....
  </code></pre>
  <p>Here is my package reference file</p>
  <pre><code>&quot;restore&quot;:{&quot;projectUniqueName&quot;:&quot;/Users/mac/Documents/GitHub/test-task-for-backend-stack/Server/Server.csproj&quot;,
      &quot;projectName&quot;:&quot;Server&quot;,&quot;projectPath&quot;:&quot;/Users/mac/Documents/GitHub/test-task-for-backend-stack/Server/Server.csproj&quot;,
      &quot;outputPath&quot;:&quot;/Users/mac/Documents/GitHub/test-task-for-backend-stack/Server/obj/&quot;,&quot;projectStyle&quot;:
      &quot;PackageReference&quot;,&quot;originalTargetFrameworks&quot;:[&quot;net6.0&quot;],&quot;sources&quot;:{&quot;https://api.nuget.org/v3/index.json&quot;:{}},
      &quot;frameworks&quot;:{&quot;net6.0&quot;:{&quot;targetAlias&quot;:&quot;net6.0&quot;,&quot;projectReferences&quot;:{}}},
      &quot;warningProperties&quot;:{&quot;warnAsError&quot;:[&quot;NU1605&quot;]}}&quot;frameworks&quot;:{&quot;net6.0&quot;:
          {&quot;targetAlias&quot;:&quot;net6.0&quot;,&quot;dependencies&quot;:{&quot;EntityFramework&quot;:
              {&quot;target&quot;:&quot;Package&quot;,&quot;version&quot;:&quot;[6.4.4, )&quot;},
              &quot;Microsoft.EntityFrameworkCore.Design&quot;:{&quot;include&quot;:&quot;Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive&quot;,
              &quot;suppressParent&quot;:&quot;All&quot;,&quot;target&quot;:&quot;Package&quot;,&quot;version&quot;:&quot;[5.0.0, )&quot;},
              &quot;Microsoft.EntityFrameworkCore.SqlServer&quot;:{&quot;target&quot;:&quot;Package&quot;,&quot;version&quot;:&quot;[5.0.0, )&quot;},
              &quot;Swashbuckle.AspNetCore&quot;:{&quot;target&quot;:&quot;Package&quot;,&quot;version&quot;:&quot;[5.6.3, )&quot;}},
              &quot;imports&quot;:[&quot;net461&quot;,&quot;net462&quot;,&quot;net47&quot;,&quot;net471&quot;,&quot;net472&quot;,&quot;net48&quot;],
              &quot;assetTargetFallback&quot;:true,&quot;warn&quot;:true,
              &quot;frameworkReferences&quot;:{&quot;Microsoft.AspNetCore.App&quot;:{&quot;privateAssets&quot;:&quot;none&quot;},
              &quot;Microsoft.NETCore.App&quot;:{&quot;privateAssets&quot;:&quot;all&quot;}},
          &quot;runtimeIdentifierGraphPath&quot;:&quot;/usr/local/share/dotnet/sdk/6.0.100-preview.6.21355.2/RuntimeIdentifierGraph.json&quot;}}
  </code></pre>
  <p>It's been already a few days. And I'm becoming really confused and mad.
  Why is this happening.. and why there is not that much info about this type of error in the internet. Please, just point me in the right direction..</p>