-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
EF Core 3.0 In Memory DB Set Primary Key Next Rec Id #18187
Comments
@aherrick Given that this was a workaround for issues in-memory value generation which have been fixed in 3.0, can you provide some more details as to why it is that you still need to do this? |
we need a way to insert a record into a blank the in memory DB Table with a certain Primary Key. |
@aherrick That should work. If it doesn't, then please post a small, runnable project/solution that demonstrates the issue. |
its already posted above :) |
@aherrick Changing your code as follows works for me: // force next student id inserted to be 6
// Not needed: _ctx.SetNextIdValueForTable(typeof(Student), 6);
_ctx.Students.Add(new Student()
{
Id = 6,
StudentName = "Andrew"
}); |
In EF Core 2.2 In Memory DB we forced our next primary key using a method like this:
In 3.0, it doesn't seem to work anymore. Then next record I insert is always PK 1.
Spike code sample:
EFCore3MemorySetRecId.zip
The text was updated successfully, but these errors were encountered: