Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when creating EF Core Migration #5680

Open
1 task done
fkamp opened this issue Sep 11, 2024 · 0 comments
Open
1 task done

Issue when creating EF Core Migration #5680

fkamp opened this issue Sep 11, 2024 · 0 comments

Comments

@fkamp
Copy link

fkamp commented Sep 11, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

There are some discussion (e.g., #398) about how to run migrations. However, I ran into the issue in creating migrations. It's working as long as I use something like this builder.AddNpgsqlDbContext<ApplicationDbContext>(ServiceNames.DATABASE_EMPLS.NAME). When I add builder.AddNpgsqlDataSource(ServiceNames.DATABASE_EMPLS.NAME) I get the following error with the command
dotnet ef migrations add update -p ..\AspireApp.Data.Postgres\

Unable to create a 'DbContext' of type ''. The exception 'ConnectionString is missing. It should be provided in 'ConnectionStrings:employee-db' or under the 'ConnectionString' key in 'Aspire:Npgsql' configuration section.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

Full example: https://github.com/fkamp/aspire-ef-migration-issue
Can someone give me a pointer if that's my incompetency or if it's a bug.

Thanks!

Expected Behavior

After issuing dotnet ef migrations add update -p ..\AspireApp.Data.Postgres\ migrations are added to the project without any error.

Steps To Reproduce

Clone and run https://github.com/fkamp/aspire-ef-migration-issue

Exceptions (if any)

Unable to create a 'DbContext' of type ''. The exception 'ConnectionString is missing. It should be provided in 'ConnectionStrings:employee-db' or under the 'ConnectionString' key in 'Aspire:Npgsql' configuration section.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

.NET Version info

.NET SDK:
Version: 8.0.400
Commit: 36fe6dda56
Workload version: 8.0.400-manifests.f51a3a6b
MSBuild version: 17.11.3+0c8610977

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.400\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[aspire]
Installation Source: SDK 8.0.400, VS 17.11.35303.130
Manifest Version: 8.2.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.0\WorkloadManifest.json
Install Type: FileBased

Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5

.NET SDKs installed:
8.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 11, 2024
@davidfowl davidfowl added bug Something isn't working area-docs and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners bug Something isn't working labels Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants