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

Problem with combined pk #31

Open
fuzolan opened this issue Nov 19, 2018 · 5 comments
Open

Problem with combined pk #31

fuzolan opened this issue Nov 19, 2018 · 5 comments

Comments

@fuzolan
Copy link

fuzolan commented Nov 19, 2018

If you use a combined pk then there is an issue that you can not delete those rows. you can create it and they will be no record in history table. But a remove returns in an error. Tested with mssql.

@rigofunc
Copy link
Member

rigofunc commented Dec 3, 2018

Please provide the detail exception info

@matthieume
Copy link

matthieume commented Dec 6, 2019

I was having the exact same issue.

To reproduce, create an entity with a composite primary key of 2 strings properties:

class MyObject()
{
public string StringA { get; set; }
public string StringB { get; set; }
}

Define the primarykey with :
modelBuilder.Entity()
.HasKey(t => new { t.StringA, t.StringB });

Autohistory is working fine when adding (as the RowId is empty), but raising an exception on delete (and I suppose any other modifications).
The exception I get is : "Data too long for column 'RowId' at row 1"

This is because the default RowIdMaxLength is setup to 50 (smaller than the expected key).

@fuzolan the solution is to raise the RowIdMaxLength in AutoHistoryOptions to match your app need.

Edit: I would say that @xyting you could add a note on the wiki about composite primary key and close this issue.

@rigofunc
Copy link
Member

Yes, have some issues about composite primary key, but I think maybe have any solution can solve this issues

@ghost
Copy link

ghost commented Feb 20, 2020

Does Autohistory not currently support composite keys? I cannot get any tables with them to push history. If you have a fix, is this going to be put in place soon, or should I adjust my tables instead?

@j5aenz
Copy link

j5aenz commented Aug 18, 2020

i also have this issue, for about 8 months now. and oddly, after i refactored these tables to have single column primary keys they are still being excluded from the autohistory. And it is passing through the same .EnsureAutoHistory() fxn as the rest. Any tips @xyting ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants