Problems with Migration

Asked

Viewed 192 times

0

I’m developing an application using DDD architecture. In my Infra layer, I have my data models, all based on Code First. I’m trying to use the Mysql as database. I have installed everything that was needed (EPH, Mysqlconnector) and others more than are needed.

It turns out that when I try to apply the Migration get the error:

Case 1: When I apply the Add-Migration

PM> Add-Migration
cmdlet Add-Migration na posição de comando 1 do pipeline
Forneça valores para os seguintes parâmetros:
Name:

What should be provided for that "Name":

Case 2: When providing the name of the database listed in ConnectionString

NOTE: I provide such value, because I do not know what should be passed as explained above.

The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      1.0.11 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      1.0.12 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      1.1.8 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      1.1.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.4 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

How to solve such a problem?

Thanks for your attention.

  • 1

    He is asking you for the name of your Migration. Each Migration has its own name, so you can identify and reverse the modifications. https://docs.microsoft.com/pt-br/ef/core/managing-schemas/migrations/

  • OK. Thank you for your attention. The problem has been solved.

1 answer

1

In the use of Migration you will have to get used to some commands:

Add-Migration <nome-da-migration>

To return to a specific version:

update-database –target "<nome-da-migration>" -Script -Force

Update your base with domain changes:

update-database -script

The -Script: parameter is used to return the script to be executed in the database, if you do not enter the parameter, it will be automatically submitted in the database.

The -Force parameter is required when there is some kind of conflict or structure modification that cannot be modified with a simple script. With the use of -Force it creates a script for breaking the possible relationship. This action, if you are using a production database, will erase the data contained in the database. Always good to be cautious in the use of Migrations and advise not to use on a production basis. Only for development.

There are other parameters still like -Verbose: It only serves to display a log of what Migrations is running during the update-database run.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.