-
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
Cannot use IDENTITY_INSERT before AddRange to seed database #8104
Labels
closed-no-further-action
The issue is closed and no further action is planned.
Comments
Yeah I am.. I was trying to generalize the code and messed up on the copy/paste. :) I will update and verify that it still is not working. |
@ajcvickers I was able to figure it out. Needed the OpenConnection command before the SQL. Here is a repo for where I was able to repro it for those in the future. |
divega
added
the
closed-no-further-action
The issue is closed and no further action is planned.
label
May 8, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After scaffolding a database with the Migration tool, I am attempting to seed a database using data pulled from an existing database. This data has been generated using the
Generate Scripts
tool inside SSMS and then converted to code (lists of data models) and then called by usingEntity.AddRange()
.Many of the entities have pre-existing relationships & keys that need to be preserved for the application to function properly. I attempted to use a number of different methods to allow for
SET IDENTITY_INSERT ON
but nothing I have tried has worked.If you are seeing an exception, include the full exceptions details (message and stack trace).
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
EntityTable DataModel
ModelCreation
Context Setup
EnsureSeedData Attempt #1
EnsureSeedData Attempt #2
This is the log for the above.
Still fails.
EnsureSeedData Attempt #3
This is the exception for the above.
Still fails.
Further technical details
EF Core version: 1.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017
The text was updated successfully, but these errors were encountered: