Have this entity in domain project:
public class DepartmentAuditProductCopy : AuditedAggregateRoot<int>, ISoftDelete
{
public int DepartmentAuditId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public bool IsAdditionalSku { get; set; }
public bool IsDeleted { get; set; }
}
DB set is added as below:
public DbSet<DepartmentAuditProductCopy> DepartmentAuditProductCopy { get; set; }
Below is the code in DepartmentCopyDbContextModelCreatingExtensions
public static void ConfigureDepartmentCopy(
this ModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
builder.Entity<DepartmentAuditProductCopy>(b =>
{
b.ToTable("DepartmentAuditProductCopy", DepartmentCopyDbProperties.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.DepartmentAuditId).IsRequired();
b.Property(x => x.ProductId).IsRequired();
b.Property(x => x.Quantity).IsRequired();
b.Property(x => x.IsAdditionalSku).IsRequired();
b.Property(x => x.IsDeleted).IsRequired();
});
}
Have below DTOs in Contracts project:
public class DepartmentAuditProductCopyDto : AuditedEntityDto<int>
{
public int DepartmentAuditId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public bool IsAdditionalSku { get; set; }
public bool IsDeleted { get; set; }
}
public class CreateUpdateDepartmentAuditProductCopyDto : AuditedEntityDto<int>
{
public int DepartmentAuditId { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public bool IsAdditionalSku { get; set; }
public bool IsDeleted { get; set; }
}
Below is the mapper code: public DepartmentCopyApplicationAutoMapperProfile() { CreateMap<DepartmentAuditProductCopy, DepartmentAuditProductCopyDto>().ReverseMap(); CreateMap<DepartmentAuditProductCopy, CreateUpdateDepartmentAuditProductCopyDto>().ReverseMap(); }
Have below interface in contracts project
public interface IDepartmentAuditDetailsCopyAppService : ICrudAppService<
DepartmentAuditProductCopyDto,
int,
PagedAndSortedResultRequestDto,
CreateUpdateDepartmentAuditProductCopyDto>
{
Task OperationSaveToDbIssue(List<DepartmentAuditProductCopyDto> records);
}
Below is the service code:
public class DepartmentAuditDetailCopyAppService : CrudAppService<
DepartmentAuditProductCopy,
DepartmentAuditProductCopyDto,
int,
PagedAndSortedResultRequestDto,
CreateUpdateDepartmentAuditProductCopyDto>,
IDepartmentAuditDetailsCopyAppService
{
private readonly IRepository<DepartmentAuditProductCopy, int> _repository;
public DepartmentAuditDetailCopyAppService(IRepository<DepartmentAuditProductCopy, int> repository) : base(repository)
{
_repository = repository;
}
public async Task OperationSaveToDbIssue(List<DepartmentAuditProductCopyDto> records)
{
try
{
var updateRecords = records.Where(rec => rec.Id != 0).ToList();
var updateEntities = ObjectMapper.Map<List<DepartmentAuditProductCopyDto>, List<DepartmentAuditProductCopy>>(updateRecords);
await _repository.UpdateAsync(updateEntities[0], true);
}
catch (System.Exception)
{
throw new UserFriendlyException("Some-Error-Occured");
}
}
}
When executing OperationSaveToDbIssue end point using below payload [ { "id": 1, "creationTime": "2023-02-24T05:23:00.294Z", "creatorId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "lastModificationTime": "2023-02-24T05:23:00.294Z", "lastModifierId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "DepartmentAuditId": 1, "productId": 1, "quantity": 1, "isAdditionalSku": true, "isDeleted": false } ]
The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
ABP Framework version: v5.3.3
UI type: Blazor
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): Separated Identity server
Exception message and stack trace: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
Steps to reproduce the issue:" below are the steps to reproduce error
• I have an entity in ModuleA as below: public class ProductOneColumn { [Key] public int Id { get; set; } public string ProductCode { get; set; } }
• Added DB set for this in ModuleADbContext public DbSet<ProductOneColumn> ProductOneColumn { get; set; }
• Below is the code in ModuleADbContextModelCreatingExtensions builder.Entity<ProductOneColumn>(b => { b.ToTable("ProductOneColumn", ProductConstants.DbSchema); b.ConfigureByConvention(); b.Property(x => x.ProductCode).HasMaxLength(8); });
• I have exactly the same entity in ModuleB as well (This entity will also use same DB table being used by ProductOneColumn entity in ModuleA): public class ProductOneColumn { [Key] public int Id { get; set; } public string ProductCode { get; set; } }
• Added DB set for this in ModuleBDbContext public DbSet<ProductOneColumn> ProductOneColumn { get; set; }
• Below is the code in ModuleBDbContextModelCreatingExtensions
builder.Entity<ProductOneColumn>(b => { b.ToTable("ProductOneColumn", FedExConstants.DbSchema, t => t.ExcludeFromMigrations()); b.ConfigureByConvention(); b.Property(x => x.ProductCode).HasMaxLength(8); });
Note: Two different entities in both the modules are trying to access the same table and Only difference between code in both the modules is that in ModuleBDbContextModelCreatingExtensions I have added b.ToTable("ProductOneColumn", FedExConstants.DbSchema, t => t.ExcludeFromMigrations()); instead of b.ToTable("ProductOneColumn", ProductConstants.DbSchema);
• In AppDBContext I have 2 method calls (this code was automatically added when I added modules) builder.ConfigureModuleA(); builder.ConfigureModuleB();
Now when I run API and click on authorize, I get below error: InvalidOperationException: Cannot use table 'ProductOneColumn' for entity type 'ProductOneColumn' since it is being used for entity type 'ProductOneColumn' and potentially other entity types, but there is no linking relationship. Add a foreign key to 'ProductOneColumn' on the primary key properties and pointing to the primary key on another entity type mapped to 'ProductOneColumn'.
• If I comment out builder.ConfigureModuleB(); then It works. However I am not aware of impact of commenting out this line of code.
An unhandled exception occurred while processing the request. AbpException: Could not find the bundle file '/libs/bootstrap/css/bootstrap.css' for the bundle 'Blazor.LeptonXTheme.Global'! Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpTagHelperResourceService.ProcessAsync(ViewContext viewContext, TagHelper tagHelper, TagHelperContext context, TagHelperOutput output, List<BundleTagHelperItem> bundleItems, string bundleName)
Stack Query Cookies Headers Routing AbpException: Could not find the bundle file '/libs/bootstrap/css/bootstrap.css' for the bundle 'Blazor.LeptonXTheme.Global'! Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpTagHelperResourceService.ProcessAsync(ViewContext viewContext, TagHelper tagHelper, TagHelperContext context, TagHelperOutput output, List<BundleTagHelperItem> bundleItems, string bundleName) Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpBundleTagHelperService<TTagHelper, TService>.ProcessAsync(TagHelperContext context, TagHelperOutput output) Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, int i, int count) SG.RISE.Blazor.Pages.Pages__Host.<ExecuteAsync>b__16_0() in _Host.cshtml + <abp-style-bundle name="@BlazorLeptonXThemeBundles.Styles.Global" /> Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync() SG.RISE.Blazor.Pages.Pages__Host.ExecuteAsync() in _Host.cshtml + <html lang="@CultureInfo.CurrentCulture.Name" dir="@rtl"> Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts) Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable<int> statusCode) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0<TFilter, TFilterAsync>(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass6_1+<<UseMiddlewareInterface>b__1>d.MoveNext() Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass6_1+<<UseMiddlewareInterface>b__1>d.MoveNext() Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass6_1+<<UseMiddlewareInterface>b__1>d.MoveNext() Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass6_1+<<UseMiddlewareInterface>b__1>d.MoveNext() Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass6_1+<<UseMiddlewareInterface>b__1>d.MoveNext() Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
Below is the complete exception:
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values. at Microsoft.Data.SqlClient.SqlBuffer.get_String() at lambda_method3306(Closure, QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
** NOTE:** We are currently manually merging code from blazor assembly (non commercial) to blazor server side solution (abp commercial license). Same code is working in old solution.
Can we connect over the call please?
Hi,
I have created an AppService in Application project using below code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public class LocationAppService : CrudAppService< Location, LocationDto, int, PagedAndSortedResultRequestDto, CreateUpdateLocationDto>, ILocationAppService
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
In blazor page I have added below code:
@inherits AbpCrudPageBase<ILocationAppService, LocationDto, int, PagedAndSortedResultRequestDto, CreateUpdateLocationDto>
AND
inside OnInitializedAsync() method I am writing below inbuilt method:
await AppService.GetAsync(LocationId); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
**NOTE: Same code is working in non commercial web assembly solution. it stopped working when we are manually merging code to commercial server assembly solution. Do we need to make any specific changes in entity or service craetion etc. when migrtaing? **
hi
If you can share a simple project to reproduce that will be great.
liming.ma@volosoft.com
It is difficult to setup a new project again. Can we connect over the call now?
We are setting up ABP commercial projects using Azure WebApps and administration menu is not visible. Administration menu item is visible in local but missing when deploying it in Azure web apps service. Both from local and Azure web app database being used is same.
Do I need to enable websocket only on blazor webapp or also in Authserver and HTTPAPI host webapps?
Enabled web socket but now the azure site is not loading throwing 500 error. Please check email have shared logs.