May 19, 2024

.net core api creation isuess &fixes | System.InvalidOperationException: Unable to resolve service for type

Error: response status is 500 Response body Download System.InvalidOperationException: Unable to resolve service for type ‘Crowdrob.BAL.Interfaces.IOrderItemsService’ while attempting to activate ‘Crowdrob.API.Controllers.OrderItemsController’. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ThrowHelperUnableToResolveService(Type type, Type requiredBy) at lambda_method10(Closure, IServiceProvider, Object[]) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext) Solutions: Issues coming because you forgot to add the services into the program.cs file: builder.Services.AddScoped<IOrderItemsService, OrderItemsService>(); builder.Services.AddScoped<IPaymentService, PaymentService>();   Issues: Cannot insert […]

.net core api creation isuess &fixes | System.InvalidOperationException: Unable to resolve service for type Read More »

Asp.net core mvc code first approach migration issues & fixes| failed executing DbCommand| LTER TABLE DROP COLUMN failed | Cannot find the object “tablename” because it does not exist

Issues: Failed executing DbCommand (68ms) [Parameters=[], CommandType=’Text’, CommandTimeout=’30’] DECLARE @var0 sysname; SELECT @var0 = [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'[tblOrders]’) AND [c].[name] = N’Id’); IF @var0 IS NOT NULL EXEC(N’ALTER TABLE [tblOrders] DROP CONSTRAINT [‘ + @var0 + ‘];’); ALTER TABLE

Asp.net core mvc code first approach migration issues & fixes| failed executing DbCommand| LTER TABLE DROP COLUMN failed | Cannot find the object “tablename” because it does not exist Read More »

Scroll to Top