robisim74 / AngularSPAWebAPI

Angular Single Page Application with an ASP.NET Core Web API that uses token authentication
MIT License
231 stars 59 forks source link

MSSQL dotnet ef database update problem #32

Closed senzacionale closed 6 years ago

senzacionale commented 6 years ago
CREATE TABLE [AspNetRoles] (
    [Id] TEXT NOT NULL,
    [ConcurrencyStamp] TEXT NULL,
    [Name] TEXT NULL,
    [NormalizedName] TEXT NULL,
    CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
);: Microsoft.EntityFrameworkCore.Database.Command[200102]
      Failed executing DbCommand (9ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      CREATE TABLE [AspNetRoles] (
          [Id] TEXT NOT NULL,
          [ConcurrencyStamp] TEXT NULL,
          [Name] TEXT NULL,
          [NormalizedName] TEXT NULL,
          CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
      );
System.Data.SqlClient.SqlException (0x80131904): Column 'Id' in table 'AspNetRoles' is of a type that is invalid for use as a key column in an index.
Could not create constraint or index. See previous errors.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
ClientConnectionId:6d7fc6df-3e63-4c32-9b4f-58fc66967739
Error Number:1919,State:1,Class:16

Can you provide fix?

robisim74 commented 6 years ago

See #29

senzacionale commented 6 years ago

This is not enough, By default you not support MSSQL. So if you change DB you also need to remove default migration files.

Solution after changing DB:

Remove:

dotnet ef database update 0
dotnet ef migrations remove

Create:

dotnet ef migrations add CreateIdentity -o Data/Migrations