Base solution for your next web application
Open Closed

Querying an entity with FirstOrDefault causes update error #2466


User avatar
0
eggersa created

I ran into a rather strange issue when I try to query an entity using an IRepository with ABP 0.9.0. The exception says:

The UPDATE statement conflicted with the FOREIGN KEY constraint "FK_dbo.AbpTenants_dbo.AbpUsers_LastModifierUserId". The conflict occurred in database "PremiumHomes", table "dbo.AbpUsers", column 'Id'. The statement has been terminated.

And according to the error output the cause for this issue is the following method:

public virtual async Task<Customer> FindByNameAsync(string userName)
{
	return await _customerRepository.FirstOrDefaultAsync(customer => customer.UserName == userName);
}

However, I do not get what a select statement has to do with an update statement? What could be the actual source of this problem?

Edit: I did not run into this issue when I was using ABP 0.8.4.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    This was an old a bug in v0.9.0 (<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1042">https://github.com/aspnetboilerplate/as ... ssues/1042</a>) and fixed with v0.9.1.1. Can you upgrade to v0.9.1.1?

    Actually, it would be very good if you can upgrade to the latest version. We have added good features and many improvements/fixes after v0.9.

    Have a nice day.