EF Core + SQL Server causes Roslyn error in .NET 9 project when used with Carter

#377 · closed · 4 comments

View on GitHub ↗

TanerSaydam

## Summary When I add EF Core (with SQL Server and Tools) to a .NET 9 project using Carter, I receive a Roslyn-related error when trying to run the application or generate migrations using Code First. However, when I use only `Microsoft.EntityFrameworkCore.InMemory`, everything works fine. ## Reproduction Steps 1. Create a new .NET 9 minimal API project. 2. Add Carter. 3. Add the following packages: - Microsoft.EntityFrameworkCore.SqlServer (tried both 9.0.7 and 9.0.0) - Microsoft.EntityFrameworkCore.Tools 4. Try to run the project or execute `dotnet ef migrations add InitialCreate`. ## Error Output Unable to load one or more of the requested types. Method 'get_IsParamsArray' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. Method 'get_PartialDefinitionPart' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationPropertySymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. Method 'get_AllowsRefLikeType' in type 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationTypeParameterSymbol' from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

Comments

jchannon

Please try this https://github.com/CarterCommunity/Carter/issues/369#issuecomment-2806286819 On Sat, 19 Jul 2025 at 16:15, Taner Saydam ***@***.***> wrote: > *TanerSaydam* created an issue (CarterCommunity/Carter#377) > <https://github.com/CarterCommunity/Carter/issues/377> > Summary > > When I add EF Core (with SQL Server and Tools) to a .NET 9 project using > Carter, I receive a Roslyn-related error when trying to run the application > or generate migrations using Code First. > > However, when I use only Microsoft.EntityFrameworkCore.InMemory, > everything works fine. > Reproduction Steps > > 1. Create a new .NET 9 minimal API project. > 2. Add Carter. > 3. Add the following packages: > - Microsoft.EntityFrameworkCore.SqlServer (tried both 9.0.7 and > 9.0.0) > - Microsoft.EntityFrameworkCore.Tools > 4. Try to run the project or execute dotnet ef migrations add > InitialCreate. > > Error Output > > Unable to load one or more of the requested types. > Method 'get_IsParamsArray' in type > 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationParameterSymbol' from > assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, > Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an > implementation. > Method 'get_PartialDefinitionPart' in type > 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationPropertySymbol' from > assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, > Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an > implementation. > Method 'get_AllowsRefLikeType' in type > 'Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationTypeParameterSymbol' > from assembly 'Microsoft.CodeAnalysis.Workspaces, Version=4.8.0.0, > Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an > implementation. > > — > Reply to this email directly, view it on GitHub > <https://github.com/CarterCommunity/Carter/issues/377>, or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAAZVJWOOZGEERAD7C6DDAL3JJOI5AVCNFSM6AAAAACB4XAJKCVHI2DSMVQWIX3LMV43ASLTON2WKOZTGI2DKMZXGUYTEMI> > . > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> >

jchannon

There is a .NET 10 build with EF Core if you want to pull the code and run the sample - https://github.com/CarterCommunity/Carter/tree/net10/samples/EntityFwk

jchannon

Hopefully fixed with .NET release

TanerSaydam

With .NET 10, it works perfectly. Thank you.