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

migrationBuilder.InsertData should return SELECT scope_identity() to get LAST INSERT ID #34607

Closed
hkusulja opened this issue Sep 3, 2024 · 1 comment

Comments

@hkusulja
Copy link

hkusulja commented Sep 3, 2024

This is a feature request for migrationBuilder and its InsertData method to return SELECT scope_identity() to get LAST INSERT ID.

This is currently supported outside of migrations, after context.SaveChanges();

Scenario:
The case is when database does provide the Primary key / ID column. Example auto increment ID which is auto increment integer.
After creating new migration, inside Up() you want to Insert Data. And then you want to insert another data, which is related to first insert data, you need to know the Id value which is provided by database, and should not be provided in c# code during Up() .
Current workaround is to do manual SQL statement for getting this inside migration.

Current behavior:

Please improve this and support InsertData to return the database provided ID...

@roji
Copy link
Member

roji commented Sep 4, 2024

Duplicate of #10000

@roji roji marked this as a duplicate of #10000 Sep 4, 2024
@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@roji roji unassigned maumar Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants