EFCore.BulkExtensions icon indicating copy to clipboard operation
EFCore.BulkExtensions copied to clipboard

BulkRead not working with Postgres database when including "xmin" column

Open PatriQ94 opened this issue 1 year ago • 3 comments

What I'm trying to do is to read large amounts of data by a large list of Ids. I have a database model that looks like this:

public class Partner
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public string? FirstName { get; set; }
	
    [Timestamp]
    [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
    [Column("xmin", TypeName = "xid")]
    public uint RowVersion { get; set; }
}

Then I have a large list of Ids, which can contain hundred of thousands of records, and a query like this:

List<Guid> idsToFetch = new(); // bunch of Ids
var items = idsToFetch.Select(a => new Partner { Id = a }).ToList();
var bulkConfig = new BulkConfig
{
    UpdateByProperties = new List<string> { nameof(Partner.Id) },
};
await _context.BulkReadAsync(items, bulkConfig); 

The error I constantly keep receiving is The required column 'xmin' was not present in the results of a 'FromSql' operation.. I've tried enablind EnableShadowProperties property, as well as exclude the RowVersion property entirely, but always same error. EFCore version: 7.0.7 EFCore.BulkExtensions version: 7.1.2 Postgres version: 15.2 Any way to solve this?

PatriQ94 avatar Jun 28 '23 08:06 PatriQ94

Can confirm the issue, it happens on casting to 'List<T>', but not sure how to solve it.

borisdj avatar Jun 28 '23 13:06 borisdj

Can confirm the issue, it happens on casting to 'List', but not sure how to solve it.

I see. Is there plans perhaps to investigate this further or...?

PatriQ94 avatar Jun 30 '23 08:06 PatriQ94

I'll leave it open for now, maybe later something comes to mind.

borisdj avatar Jun 30 '23 09:06 borisdj