dotnet / dotnet/Scaffolding

API Scaffolding Fails for ASP.Net Core Api Controller

Open
#2,729 0 comments 0 reactions 0 assignees View on GitHub
area-scaffolding customer-reported
Dominant language
C#
Stars
818
Forks
260
Avg merge
1d 8h
Merged PRs (30d)
10

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.