Suppose I have added entity with some field. Again I have added new fileds to that entity and trying to update database getting below error. Pelase help me on it. Is it possible to add all migraion to one file so that it should not be confusion what is going on in migration file.
PM> update-database
Applying migration '20181216022015_Customer table added'.
Failed executing DbCommand (625ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
DECLARE @var1 sysname;
SELECT @var1 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Customer]') AND [c].[name] = N'Id');
IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Customer] DROP CONSTRAINT [' + @var1 + '];');
ALTER TABLE [Customer] ALTER COLUMN [Id] bigint NOT NULL;
System.Data.SqlClient.SqlException (0x80131904): The object 'PK_Customer' is dependent on column 'Id'.
ALTER TABLE ALTER COLUMN Id failed because one or more objects access this column.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 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, IReadOnlyDictionary2 parameterValues) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.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.OperationBase.Execute(Action action)
ClientConnectionId:9bf68424-7cbb-464a-beac-a6cab2b252da
Error Number:5074,State:1,Class:16
The object 'PK_Customer' is dependent on column 'Id'.
ALTER TABLE ALTER COLUMN Id failed because one or more objects access this column.
Erlier table name is Customer and below are my fields.
[Required] public virtual string Tags { get; set; }
[Required]
public virtual long CreatedBy { get; set; }
[Required]
public virtual DateTime CreatedDate { get; set; }
Now I ahve added two more field and want customerid will be my primary key
public virtual long CustomerId { get; set; }
public virtual string StatusId { get; set; }
After using ASP.NET Zero Power Tools for one of my module, below the error generated.
D:\Projects\Astar\angular\nswag>"..\node_modules.bin\nswag" run NSwag NPM CLI NSwag command line tool for .NET 4.6.1+ WinX64, toolchain v11.20.1.0 (NJsonSchema v9.11.0.0 (Newtonsoft.Json v9.0.0.0)) Visit http://NSwag.org for more information. NSwag bin directory: D:\Projects\Astar\angular\node_modules\nswag\bin\binaries\Win
Executing file 'D:\Projects\Astar\angular\nswag\service.config.nswag'... System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:22742 at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Net.Http.HttpClient.d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at NJsonSchema.Infrastructure.DynamicApis.d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.SwaggerDocument.d__59.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.OutputCommandBase.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.SwaggerGeneration.FromSwaggerCommand.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.SwaggerGeneration.FromSwaggerCommand.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.NSwagDocumentBase.d__40.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.NSwagDocument.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.Document.ExecuteDocumentCommand.d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.Document.ExecuteDocumentCommand.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NConsole.CommandLineProcessor.d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NConsole.CommandLineProcessor.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NConsole.CommandLineProcessor.Process(String[] args, Object input) at NSwag.Commands.NSwagCommandProcessor.Process(String[] args)child_process.js:644 throw err; ^
Error: Command failed: "D:\Projects\Astar\angular\node_modules\nswag\bin/binaries/Win/nswag.exe" run at checkExecSyncError (child_process.js:601:13) at Object.execSync (child_process.js:641:13) at Object. (D:\Projects\Astar\angular\node_modules\nswag\bin\nswag.js:43:22)
at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Function.Module.runMain (module.js:684:10) at startup (bootstrap_node.js:187:16)
Angular compilation error:
ERROR in src/app/main/customerCompany/customerCompanyInfos/create-or-edit-customerCompanyInfo-modal.component.ts(4,10): error TS2305: Module '"D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CustomerCompanyInfosServiceProxy'.
src/app/main/customerCompany/customerCompanyInfos/create-or-edit-customerCompanyInfo-modal.component.ts(4,44): error TS2305: Module '"D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CreateOrEditCustomerCompanyInfoDto'. src/app/main/customerCompany/customerCompanyInfos/customerCompanyInfos.component.ts(4,10): error TS2305: Module '"D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CustomerCompanyInfosServiceProxy'. src/app/main/customerCompany/customerCompanyInfos/customerCompanyInfos.component.ts(4,44): error TS2305: Module '"D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CustomerCompanyInfoDto'. src/app/main/customerCompany/customerCompanyInfos/view-customerCompanyInfo-modal.component.ts(3,10): error TS2305: Module '"D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies"' has no exported member 'GetCustomerCompanyInfoForView'. src/app/main/customerCompany/customerCompanyInfos/view-customerCompanyInfo-modal.component.ts(3,41): error TS2305: Module '"D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies"' has no exported member 'CustomerCompanyInfoDto'. src/shared/service-proxies/service-proxy.module.ts(8,27): error TS2339: Property 'CustomerCompanyInfosServiceProxy' does not exist on type 'typeof import("D:/Projects/Astar/angular/src/shared/service-proxies/service-proxies")'.