dotnet ef Migration add ColumnToTable RRS feed

  • Question

  • I need to modify a table within my SQL database.  I made the changes to the model.  I want to perform the migration without losing existing data.  I ran dotnet ef add ColumnChange in the folder that has the csproj file.  I didn’t get any error message.  I than run dotnet ef database update and got the following error message:

    Failed executing DbCommand (686ms) [Parameters=[], CommandType='Text', CommandTimeout='30']

    CREATE TABLE [Employee] (

        [Employee ID] int NOT NULL,

        [Badge] int NOT NULL,

        [Title] nvarchar(max) NULL,

        CONSTRAINT [PK_Employee] PRIMARY KEY ([EmployeeID])

    There is already an object name ‘Employee’  in the database

    How do I modify a table without losing data?  I’m new to this so please explain it so a four year old understand it.   Thank you in advance for your time and help.  It is very much appreciated.

    Tuesday, April 10, 2018 5:40 PM