Ao executar o comando ele falha com as msgs:
PM> update-database
Build started...
Build succeeded.
Failed executing DbCommand (13ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE `AspNetRoles` (
`Id` int NOT NULL AUTO_INCREMENT,
`Name` varchar(256) NULL,
`NormalizedName` varchar(256) NULL,
`ConcurrencyStamp` text NULL,
PRIMARY KEY (`Id`)
);
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (13ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE `AspNetRoles` (
`Id` int NOT NULL AUTO_INCREMENT,
`Name` varchar(256) NULL,
`NormalizedName` varchar(256) NULL,
`ConcurrencyStamp` text NULL,
PRIMARY KEY (`Id`)
);
MySql.Data.MySqlClient.MySqlException (0x80004005): Table 'aspnetroles' already exists
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.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 connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Table 'aspnetroles' already exists
Código do migration:
sing Microsoft.EntityFrameworkCore.Migrations;
namespace UsuariosApi.Migrations
{
public partial class usuarioadmin : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "AspNetRoles",
columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" },
values: new object[] { 99999, "827d680a-9404-4471-962a-3e222aeb4cf8", "admin", "ADMIN" });
migrationBuilder.InsertData(
table: "AspNetUsers",
columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "Email", "EmailConfirmed", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" },
values: new object[] { 99999, 0, "1d11ca38-2199-446a-a4eb-a22be449fe37", "admin@admin.com", true, false, null, "ADMIN@ADMIN.COM", "ADMIN", "AQAAAAEAACcQAAAAEBVA+w9gUFghtwZSfWJP9HZi8PYjJeZhRkls3AAbQ0WMQqSgLWtN1asG4jFJbxCwkA==", null, false, "6045940e-4756-4ff0-aac9-045b404d876a", false, "admin" });
migrationBuilder.InsertData(
table: "AspNetUserRoles",
columns: new[] { "RoleId", "UserId" },
values: new object[] { 99999, 99999 });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "AspNetUserRoles",
keyColumns: new[] { "RoleId", "UserId" },
keyValues: new object[] { 99999, 99999 });
migrationBuilder.DeleteData(
table: "AspNetRoles",
keyColumn: "Id",
keyValue: 99999);
migrationBuilder.DeleteData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 99999);
}
}
}