Skip to content
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

Missing values in target table #550

Closed
NicoKno opened this issue Oct 16, 2023 · 2 comments
Closed

Missing values in target table #550

NicoKno opened this issue Oct 16, 2023 · 2 comments
Assignees

Comments

@NicoKno
Copy link

NicoKno commented Oct 16, 2023

Description

I have this one Entity which behaves quite weird. When i sync my database with a BulkMerge the entities are beeing written, but my last two columns LinesAdded and LinesDeleted keep getting removed from the insert statement. See below. In this case I get the records in the target but only get the DefaultValue of "0" defined for the columns.
Is there some mechanism causing this?
The only option I set on the operation is KeepIdentityOnInsert = true;

Some help would be highly appreciated.

Exception

No Exception

Fiddle or Project (Optional)

SET IDENTITY_INSERT [data].[PartProgramValueChanges] ON;
MERGE INTO [data].[PartProgramValueChanges]  AS DestinationTable
USING
(
SELECT TOP 100 PERCENT * FROM (SELECT @0_0 AS [PartProgramValueChange_Id], @0_1 AS [GitCommitHashValue], @0_2 AS [GitRepository_Id], @0_3 AS [LinesAdded], @0_4 AS [LinesDeleted], @0_5 AS [PartProgram_Id], @0_6 AS [SourceTimestamp], @0_7 AS ZZZ_Index) AS StagingTable ORDER BY ZZZ_Index
) AS StagingTable
ON DestinationTable.[PartProgramValueChange_Id] = StagingTable.[PartProgramValueChange_Id]
WHEN MATCHED   THEN
UPDATE
SET     [GitCommitHashValue] = StagingTable.[GitCommitHashValue], [GitRepository_Id] = StagingTable.[GitRepository_Id], [LinesAdded] = StagingTable.[LinesAdded], [LinesDeleted] = StagingTable.[LinesDeleted], [PartProgram_Id] = StagingTable.[P
artProgram_Id], [SourceTimestamp] = StagingTable.[SourceTimestamp]
WHEN NOT MATCHED THEN
INSERT ( [PartProgramValueChange_Id], [GitCommitHashValue], [GitRepository_Id], [PartProgram_Id], [SourceTimestamp] )
VALUES ( [PartProgramValueChange_Id], [GitCommitHashValue], [GitRepository_Id], [PartProgram_Id], [SourceTimestamp] )
OUTPUT
    $action,
    StagingTable.ZZZ_Index,
    1,
    INSERTED.[LinesAdded] AS [LinesAdded_zzzinserted], INSERTED.[LinesDeleted] AS [LinesDeleted_zzzinserted]

Further technical details

  • EF version: 7.0
  • EF Extensions version: 7.100.3
  • Database Provider: SqlServer
@JonathanMagnan JonathanMagnan self-assigned this Oct 16, 2023
@JonathanMagnan
Copy link
Member

Hello @NicoKno ,

I'm not sure if I understand the problem correctly. Are you looking to be able to insert values to some properties that you have set a default value to them?

If that's the case, you should look at the ForceValueGeneratedStrategy option

Let me know if that was the cause and solution you were looking for. Otherwise, let me know more about the issue.

Best Regards,

Jon

@NicoKno
Copy link
Author

NicoKno commented Oct 17, 2023

Hi Jon,

thanks again for your help. That's actually the feature I was looking for and its nicely documented too.

Best wishes.

@NicoKno NicoKno closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants