Problem with combined pk
fuzolan opened this issue · comments
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.
Please provide the detail exception info
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.
Yes, have some issues about composite primary key, but I think maybe have any solution can solve this issues
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?