dotnet / dotnet/aspnetcore

MigrationsEndPoint throwing `InvalidOperationException: Incorrect Content-Type:` on load

Open
#46,638 13 comments 0 reactions 0 assignees View on GitHub
area-networking bug help wanted
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

I have `Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore` package installed and I use `app.UseMigrationsEndPoint()` on my `Program.cs`. Whenever I enter migrations url (/ApplyDatabaseMigrations) I get this exception:

Seems like its missing `Content-Type application/x-www-form-urlencoded` in Headers.

### Expected Behavior

It should load the migrations page correctly and include `application/x-www-form-urlencoded` Content-Type header.

### Steps To Reproduce

Run the project and go to `.../ApplyDatabaseMigrations` page
https://github.com/Hantick/EntityFrameworkCoreBug

### Exceptions (if any)

```
System.InvalidOperationException: Incorrect Content-Type:
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.GetDbContext(HttpContext context, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.InvokeCore(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
```

### .NET Version

7.0.100

### Anything else?

![image](https://user-images.githubusercontent.com/36815427/206738469-d25fdd87-3417-43c8-8b68-1a582553d9f6.png)

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.