Skip to content

Adding Migration changes namespace and classname #30091

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

Closed
SpaxR opened this issue Jan 18, 2023 · 1 comment
Closed

Adding Migration changes namespace and classname #30091

SpaxR opened this issue Jan 18, 2023 · 1 comment

Comments

@SpaxR
Copy link

SpaxR commented Jan 18, 2023

After I updated a Project from .net6 to .net7 and EntityFrameworkCore from 6 to 7 my migrations don't behave as expected.
Creating a new Migration changes the namespace from "web_manager" to "webmanager" in the new migration as well as the snapshot.
When I create another Migration after that, it behaves like the namespace is "webmanager" and puts new files in the directory webmanager.

Changing the namespace of the new migration and snapshot manually back to "web_manager" doesn't seem to change anything.
When I change the classname from "webmanagerDbContextModelSnapshot" back to "web_managerDbContextModelSnapshot" it works for the next Migration.

I know that a namespace with underscore is ugly by itself, but it's not something I can change right now without much effort.

Is it expected behavior, that special characters get removed from Migrations?
If yes, is there a way to prevent that? --namespace "web_manager" just puts the files in another directory, but doesn't prevent renaming.
I've found nothing in documentation or issues regarding this issue.

State before

Latest Migration: 20230111234031_Added_QuickFilter_Entity.cs

namespace web_manager.Migrations
{
    public partial class Added_QuickFilter_Entity : Migration
    {
[...]

web_managerDbContextModelSnapshot.cs

namespace web_manager.Migrations
{
    [DbContext(typeof(web_managerDbContext))]
    partial class web_managerDbContextModelSnapshot : ModelSnapshot
    {
[...]

First Migration after Update

20230118150116_Test.cs

namespace webmanager.Migrations
{
    /// <inheritdoc />
    public partial class Test : Migration
    {
[...]

web_managerDbContextModelSnapshot.cs

namespace webmanager.Migrations
{
    [DbContext(typeof(web_managerDbContext))]
    partial class webmanagerDbContextModelSnapshot : ModelSnapshot
    {
[...]

Command to create Migration: dotnet-ef migrations add Test

EF Core version: 6 -> 7
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET6 -> .NET7
Operating system: Windows 11
IDE: dotnet-cli

@ajcvickers
Copy link
Contributor

ajcvickers commented Jan 18, 2023

Duplicate of #29450.

@ajcvickers ajcvickers marked this as a duplicate of #29450 Jan 18, 2023
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
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