Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile error "Type 'MyMigration' already defines a member called 'Up' with the same parameter types

I have a very simple code-first dotnet core webapi project generated from netcoreapp2.1 in VSCode and I also added two migrations using dotnet ef migrations add [migration-name]. Everything seems to work as expected, except I suddenly get this compile error (you can disregard the brackets in the migration name):

Type '[migration-name]' already defines a member called 'Up' with the same parameter types

Technically I know why this happens but I'm note sure if this is intentional behavior when working with migrations. Is it expected to update the namespace every time a new migration is created or am I missing something obvious here?

I did a couple of google searches for this issue but surprisingly I did not get any hits that covered this issue.

like image 571
Stig Perez Avatar asked Dec 20 '25 03:12

Stig Perez


1 Answers

I found the cause for this - I previously removed some of the failed migrations by deleting the files instead of using dotnet ef migrations remove and so I had an obsolete .cs file with the same methods in my migration folder. Removing the file solved the problem.

like image 65
Stig Perez Avatar answered Dec 24 '25 10:12

Stig Perez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!