New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulkMerge does not use ColumnPrimaryKeyExpression #97

Closed
staff0rd opened this Issue Apr 11, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@staff0rd

staff0rd commented Apr 11, 2018

I execute the following;

var category = new GeneralLedgerCategory
{
    Id = Guid.NewGuid(),
    GeneralLedgerCode = "12345"
};

db.BulkMerge(new[] { category }, (options) =>
{
    options.ColumnPrimaryKeyExpression = type => type.GeneralLedgerCode;
});

But this fails on subsequent attempts due to a unique key constraint that exists on GeneralLedgerCode, however, I am expecting BulkMerge to be aware of this considering I have set ColumnPrimaryKeyExpression.

Investigating the profiler, I see the following ON clause within the MERGE;

ON (DestinationTable.[Id] = StagingTable.[Id] OR (DestinationTable.[Id] IS NULL AND StagingTable.[Id] IS NULL)) AND (DestinationTable.[GeneralLedgerCode] = StagingTable.[GeneralLedgerCode] OR (DestinationTable.[GeneralLedgerCode] IS NULL AND StagingTable.[GeneralLedgerCode] IS NULL))

Why is Id (primary key) in there, when I have specifically set ColumnPrimaryKeyExpression to GeneralLedgerCode?

@JonathanMagnan JonathanMagnan self-assigned this Apr 11, 2018

@JonathanMagnan

This comment has been minimized.

Member

JonathanMagnan commented Apr 11, 2018

Hello @staff0rd ,

Thank you for reporting.

By looking at our code, when no ColumnInputExpression has been provided, we map all Entity Framework columns and the key specified (Oops!).

The ColumnPrimaryKeyExpression later specify which column is used as the key. However, some column has already been flagged which is an error.

We will try to release a fix later today with this issue.

Best Regards,

Jonathan

@JonathanMagnan

This comment has been minimized.

Member

JonathanMagnan commented Apr 11, 2018

Hello @staff0rd ,

The v2.1.8 (for EF Core) has been released.

Let me know if it's work as expected or you were using another version than EF Core.

Best Regards,

Jonathan

@JonathanMagnan

This comment has been minimized.

Member

JonathanMagnan commented Apr 24, 2018

Hello @staff0rd ,

This issue will be closed since it has been resolved.

Feel free to reopen it if you feel otherwise.

Best Regards,

Jonathan

@staff0rd

This comment has been minimized.

staff0rd commented Apr 24, 2018

Thanks Jonathan, I have tested this and can confirm the fix works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment