Activities of "s.beckers"

Hi @EngincanV,

I have created a 3rd example app, of the User & UserProfile example inside an ABP framework solution: https://cdn.fuzed.app/share/abp/AbpEFCorePlayground.zip

This time the SQL query loop occurs again, within ABP framework, using the same configuration as previous example. So I think this is some framework issue that needs to be fixed.

User entity:

using System;
using Volo.Abp.Domain.Entities.Auditing;

namespace AbpEFCorePlayground.Users;

public class User : FullAuditedAggregateRoot<Guid>
{
    public User(
        Guid id,
        string name)
    {
        Id = id;
        Name = name;
    }

    private User()
    {
    }

    public string Name { get; set; }

    public UserProfile? Profile { get; set; }
}

UserProfile entity:

using System;
using Volo.Abp.Domain.Entities.Auditing;

namespace AbpEFCorePlayground.Users;

public class UserProfile : FullAuditedEntity<Guid>
{
    public Guid Id { get; set; }

    public string Bio { get; set; }

    public Guid UserId { get; set; }

    public User User { get; set; }
}

UsersDataSeedContributor:

using System;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Uow;

namespace AbpEFCorePlayground.Users;

public class UsersDataSeedContributor : IDataSeedContributor, ITransientDependency
{
    private readonly IUserRepository _userRepository;

    public UsersDataSeedContributor(IUserRepository userRepository)
    {
        _userRepository = userRepository;
    }

    [UnitOfWork]
    public virtual async Task SeedAsync(DataSeedContext context)
    {
        User user = new User(
            id: Guid.Parse("c64b873e-c067-43e0-ae00-07992a880837"),
            name: "Steff Beckers")
        {
            Profile = new UserProfile()
            {
                Bio = "Software Developer"
            }
        };

        await _userRepository.DeleteAsync(x => x.Id == user.Id);
        await _userRepository.InsertAsync(user);
    }
}

EF entity configuration:

        builder.Entity<User>(b =>
        {
            b.ToTable(AbpEFCorePlaygroundConsts.DbTablePrefix + "Users", AbpEFCorePlaygroundConsts.DbSchema);
            b.ConfigureByConvention(); //auto configure for the base class props

            b.HasOne(x => x.Profile)
                .WithOne(x => x.User)
                .HasForeignKey<UserProfile>(x => x.UserId)
                .IsRequired()
                .OnDelete(DeleteBehavior.Cascade);
        });

        builder.Entity<UserProfile>(b =>
        {
            b.ToTable(AbpEFCorePlaygroundConsts.DbTablePrefix + "UserProfiles", AbpEFCorePlaygroundConsts.DbSchema);
            b.ConfigureByConvention(); //auto configure for the base class props
        });
        
        Configure<AbpEntityOptions>(options =>
        {
            options.Entity<User>(e =>
            {
                e.DefaultWithDetailsFunc = query => query.Include(x => x.Profile);
            });
        });

App service:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpEFCorePlayground.Users;

public class UsersAppService : AbpEFCorePlaygroundAppService, IUsersAppService
{
    private readonly IUserRepository _userRepository;

    public UsersAppService(IUserRepository userRepository)
    {
        this._userRepository = userRepository;
    }

    public async Task DeleteUserProfileAsync()
    {
        var user = await _userRepository.GetAsync(x => x.Id == Guid.Parse("c64b873e-c067-43e0-ae00-07992a880837"));

        user.Profile = null;

        await _userRepository.UpdateAsync(user);
    }
}

Best regards, Steff Beckers

Hi @EngincanV,

I've tested IsRequired(false) and it solves the query issue, but the Author itself isn't deleted. An author can't exist on its own in this case and now we have a "ghost" Author record, since BookId is now allowed to be NULL. So I don't think we should use IsRequired(false). IsRequired configures whether this is a required relationship (i.e. whether the foreign key property(s) can be assigned null). It doesn't ensure that a Book requires an Author. It only ensures that the FK is required/can't be NULL => an Author must have a BookId.

Also see the EF core docs: https://learn.microsoft.com/en-us/ef/core/modeling/relationships/one-to-one#required-one-to-one

I've created a new and better (relation wise) example using the ASP.NET Core Web API template, where the removal works as expected: https://cdn.fuzed.app/share/abp/EFCorePlayground.zip

Entities:

public class User
{
    public Guid Id { get; set; }

    public string Name { get; set; }

    public UserProfile? Profile { get; set; }
}

public class UserProfile
{
    public Guid Id { get; set; }

    public string Bio { get; set; }

    public Guid UserId { get; set; }

    public User User { get; set; }
}

DbContext:

public class AppDbContext : DbContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
    {
    }

    public DbSet<User> Users { get; set; }

    public DbSet<UserProfile> UserProfiles { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<User>()
            .HasOne(x => x.Profile)
            .WithOne(x => x.User)
            .HasForeignKey<UserProfile>(x => x.UserId)
            .IsRequired()
            .OnDelete(DeleteBehavior.Cascade);
    }
}

Controller:

[Route("api/[controller]")]
[ApiController]
public class UsersController : ControllerBase
{
    private readonly AppDbContext _context;

    public UsersController(AppDbContext context)
    {
        _context = context;
    }

    ...

    // DELETE: api/users/{id}/profile
    [HttpDelete("{id}/profile")]
    public async Task<IActionResult> DeleteUserProfile(Guid id)
    {
        User? user = await _context.Users.Include(x => x.Profile).FirstOrDefaultAsync(x => x.Id == id);
        if (user == null)
        {
            return NotFound();
        }

        user.Profile = null;

        await _context.SaveChangesAsync();

        return NoContent();
    }
    
    ...
}

Thanks in advance!

Best regards, Steff Beckers

  • ABP Framework version: v9.0.4
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Steps to reproduce the issue:

Hi,

I've created a test project to simulate the issue: http://cdn.fuzed.app/share/abp/AbpHardDelete.zip

using System;
using System.Threading.Tasks;

namespace AbpHardDelete.Books;

public class BooksAppService : AbpHardDeleteAppService, IBooksAppService
{
    private readonly IBookRepository _bookRepository;

    public BooksAppService(IBookRepository bookRepository)
    {
        _bookRepository = bookRepository;
    }

    public async Task HardDeleteTest()
    {
        Book book = await _bookRepository.GetAsync(Guid.Parse("bef9de79-60d9-4837-840c-f2d04cd58514"));

        book.Author = null;

        await _bookRepository.UpdateAsync(book);
    }
}

The following request fails after timeout:

The database is spammed with queries:

Do I miss something here or is this a framework / EF core level issue?

Best regards, Steff Beckers

It seems I still had to clear my local NuGet cache to resolve the warnings.

When building our backend API we still get warnings for each project. Maybe related to the Cloudflare issue?

MyCompany.DbMigrator.csproj : warning NU1900: Error occurred while getting package vulnerability data: Unable to load the service index for source https://nuget.abp.io/aa3334f2-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/v3/index.json.
MyCompany.Application.csproj : warning NU1900: Error occurred while getting package vulnerability data: Unable to load the service index for source https://nuget.abp.io/aa3334f2-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/v3/index.json.
...

I got the same issue

Hi

I'll try that.

Thanks!

While investigating the bundling I saw a lot of logs related to the bundling. Can you check if this is correct, since I see a lot of the same files getting bundled and minified? Or are these from multiple requests? Also, notice the timestamps.

https://cdn.fuzed.app/share/abp/main-http-api-6f5c75958b.log

Thanks!

  • ABP Framework version: v8.1.4
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:

The following exception occurs when our API is running for a few days in production. Logged out users are not able to login anymore due to this exception which results in a 500 error page instead of the login page.

We're hosting the API as a published release build in a linux docker container. It seems that the BundleManager still watches for file changes? Is this correct behaviour in a release build? Restarting the API container only fixes the issue temporary.

2024-11-05 09:21:35Z [ERR] Connection id ""0HN7TAA59SCFI"", Request id ""0HN7TAA59SCFI:00000003"": An unhandled exception was thrown by the application.
System.IO.IOException: The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
   at Microsoft.Extensions.FileProviders.CompositeFileProvider.Watch(String pattern)
   at Volo.Abp.AspNetCore.VirtualFileSystem.WebContentFileProvider.Watch(String filter)
   at Microsoft.Extensions.FileProviders.CompositeFileProvider.Watch(String pattern)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.WatchChanges(BundleCacheItem cacheValue, List`1 files, String bundleRelativePath)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.&lt;&gt;c__DisplayClass17_0.&lt;AddToBundleCache&gt;b__0()
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleCache.GetOrAdd(String bundleName, Func`1 factory)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.AddToBundleCache(String bundleName, IBundler bundler, List`1 bundleFiles)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.GetBundleFilesAsync(BundleConfigurationCollection bundles, String bundleName, IBundler bundler)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.BundleManager.GetStyleBundleFilesAsync(String bundleName)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpTagHelperStyleService.GetBundleFilesAsync(String bundleName)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpTagHelperResourceService.ProcessAsync(ViewContext viewContext, TagHelper tagHelper, TagHelperContext context, TagHelperOutput output, List`1 bundleItems, String bundleName)
   at Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers.AbpBundleTagHelperService`2.ProcessAsync(TagHelperContext context, TagHelperOutput output)
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.&lt;RunAsync&gt;g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count)
   at AspNetCoreGeneratedDocument.Themes_Default_Layouts_Account.&lt;&gt;c__DisplayClass18_0.&lt;&lt;ExecuteAsync&gt;b__0>d.MoveNext() in /src/modules/Fuzed.DefaultTheme/src/Fuzed.AspNetCore.Mvc.UI.Theme.Default/Themes/Default/Layouts/Account.cshtml:line 41
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
   at AspNetCoreGeneratedDocument.Themes_Default_Layouts_Account.ExecuteAsync() in /src/modules/Fuzed.DefaultTheme/src/Fuzed.AspNetCore.Mvc.UI.Theme.Default/Themes/Default/Layouts/Account.cshtml:line 26
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextResultFilterAsync&gt;g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeResultFilters&gt;g__Awaited|28_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextResourceFilter&gt;g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeFilterPipelineAsync&gt;g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeAsync&gt;g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeAsync&gt;g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Volo.Abp.AspNetCore.Security.Claims.AbpDynamicClaimsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Builder.ApplicationBuilderAbpOpenIddictMiddlewareExtension.&lt;&gt;c__DisplayClass0_0.&lt;&lt;UseAbpOpenIddictValidation&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Fuzed.FuzedHttpApiHostModule.&lt;&gt;c.&lt;&lt;OnApplicationInitialization&gt;b__1_0>d.MoveNext() in /src/src/Fuzed.HttpApi.Host/FuzedHttpApiHostModule.cs:line 157
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.&lt;&gt;c__DisplayClass2_0.&lt;&lt;CreateMiddleware&gt;b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Can you share this project or make a simple project?

I can't share our source code. With the test project I tried to create, I coudn't reproduce the same warnings..

Showing 11 to 20 of 47 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 12, 2025, 10:36
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.