The Exception:
System.InvalidOperationException: 'The LINQ expression 'DbSet() .Where(k => (GroupAddress)k.Address == __notification_Destination_0)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'.
The source code which leads to the aforementioned exception
// works
var x = await dbContext.AddressConfigurations.SingleOrDefaultAsync(c => c.Id == 1);
// fails with the exception below
// Single() or First() makes no difference regarding the exception. Should be Single() but I have no unique constraint so far.
var y = await dbContext.AddressConfigurations.FirstOrDefaultAsync(c => c.Address == notification.Destination);
The database model
public class AddressConfiguration
{
public AddressConfiguration(string address, string dataType)
{
Address = address;
DataType = dataType;
}
public int Id { get; set; }
public string Address { get; set; }
public string DataType { get; set; }
public string? Location { get; set; }
}
Is there anything I'm missing here? Do I need to define an index for that column?