Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dlagg/07e81ed674daf646fc17870969b6b82c to your computer and use it in GitHub Desktop.
Save dlagg/07e81ed674daf646fc17870969b6b82c to your computer and use it in GitHub Desktop.
The Model is correct, "dotnet ef migrations add" WORKS , no .db files but when I apply the migration I get this error. The Table User already exist.
dotnet ef database update -v --context ClaveSolDbContext
Using project '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/ClaveSol.csproj'.
Using startup project '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/ClaveSol.csproj'.
Writing '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/obj/ClaveSol.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpmYoIe7.tmp /verbosity:quiet /nologo /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/ClaveSol.csproj
Writing '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/obj/ClaveSol.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpG5zdL9.tmp /verbosity:quiet /nologo /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/ClaveSol.csproj
Build started...
dotnet build /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/ClaveSol.csproj /verbosity:quiet /nologo
Compilación correcta.
0 Advertencia(s)
0 Errores
Tiempo transcurrido 00:00:05.46
Build succeeded.
dotnet exec --depsfile /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/bin/Debug/netcoreapp3.1/ClaveSol.deps.json --additionalprobingpath /home/dlag/.nuget/packages --runtimeconfig /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/bin/Debug/netcoreapp3.1/ClaveSol.runtimeconfig.json /home/dlag/.nuget/packages/dotnet-ef/3.1.3/tools/netcoreapp3.1/any/tools/netcoreapp2.0/any/ef.dll database update --context ClaveSolDbContext --assembly /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/bin/Debug/netcoreapp3.1/ClaveSol.dll --startup-assembly /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/bin/Debug/netcoreapp3.1/ClaveSol.dll --project-dir /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/ --language C# --working-dir /home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol --verbose --root-namespace ClaveSol
Using assembly 'ClaveSol'.
Using startup assembly 'ClaveSol'.
Using application base '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/bin/Debug/netcoreapp3.1'.
Using working directory '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol'.
Using root namespace 'ClaveSol'.
Using project directory '/home/dlag/DAW/PROYECTO-FINAL-DAW/ClaveSol/'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'ApplicationDbContext'.
Found DbContext 'ClaveSolDbContext'.
Finding DbContext classes in the project...
Using context 'ClaveSolDbContext'.
Finding design-time services for provider 'Microsoft.EntityFrameworkCore.Sqlite'...
Using design-time services from provider 'Microsoft.EntityFrameworkCore.Sqlite'.
Finding design-time services referenced by assembly 'ClaveSol'.
No referenced design-time services were found.
Finding IDesignTimeServices implementations in assembly 'ClaveSol'...
No design-time services were found.
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE "User" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_User" PRIMARY KEY AUTOINCREMENT,
"Name" TEXT NOT NULL,
"Surname" TEXT NOT NULL,
"Mail" TEXT NOT NULL,
"Premium" INTEGER NOT NULL,
"OwnerID" TEXT NULL,
"Status" INTEGER NOT NULL
);
Failed executing DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE "User" (
"Id" INTEGER NOT NULL CONSTRAINT "PK_User" PRIMARY KEY AUTOINCREMENT,
"Name" TEXT NOT NULL,
"Surname" TEXT NOT NULL,
"Mail" TEXT NOT NULL,
"Premium" INTEGER NOT NULL,
"OwnerID" TEXT NULL,
"Status" INTEGER NOT NULL
);
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: 'table "User" already exists'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
SQLite Error 1: 'table "User" already exists'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment