dotnet / Scaffolding

Code generators to speed up development.
MIT License
624 stars 224 forks source link

API Scaffolding Fails for ASP.Net Core Api Controller #2729

Open johnholliday opened 2 months ago

johnholliday commented 2 months ago

1) Create an Asp.Net Core WebApi project 2) Add a Resources file (SampleProject.WebApi.Properties.Resources.resx). 3) Add a text file to the Resources.resx file. 4) Add an EntityFrameworkCore SQL DbContext 'SampleDbContext' with a 'Client' Entity 5) Run the Controller scaffolding tool 7) Select 'SampleDbContext' and 'Client' entity for a 'ClientsController'

Error

There was an error running the selected code generator: 
'Could not find the resource "SampleProject.WebApi.Properties.Resources.resources" among the resources "" embedded in the assembly "SampleProject.WebApi", nor among the resources in any satellite assembles for the specified culture.  
Perhaps the resources were embedded with an incorrect name.'

 at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)

 at Microsoft.EntityFrameworkCore.Design.DbContextActivator.CreateInstance(Type contextType, Assembly startupAssembly, IOperationReportHandler reportHandler, String[] args)
 at Microsoft.EntityFrameworkCore.Design.DbContextActivator.CreateInstance(Type contextType, Assembly startupAssembly, IOperationReportHandler reportHandler)
 at Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.EntityFrameworkModelProcessor.TryCreateContextUsingAppCode(Type dbContextType, Type startupType)

Include provider and version information

Target framework: .NET 8.0 Operating system: Windows 11 IDE: Visual Studio 2022 17.9.6