-
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
Running dnx ef dbcontext scaffold throws 'The given key was not present in the dictionary.' dnvm 1.0.0-rc1-final #4031
Comments
to clarify a little: when using a test database with very few tables, model generation succeeds. when using the ACTUAL database with a ton of tables, I get the error. |
we removed all non-clustered indexes and the model generation was successful |
I'm doing the same thing, and getting the same error. Running "dnx --version" gives me: Running "dnx ef --version" gives me: Am I doing something wrong, or do I need to update my tooling? |
See #3861 and #4566 for possible reasons for this. If you have control over the DB schema you may be able to avoid the issues that cause this (it's usually to do with tables with the same name in different schemas or indexes with the same name on different tables), but if not you will need to update your tooling to one of the nightly builds. Note: we are commonly experiencing difficulties with nightly builds for other reasons at the moment - so for now I'd recommend fixing the DB schema and sticking with RC1 if you can. |
I'm able to generate models for a test database, but for a complex db I get the error below. A great deal of googling yielded mostly ef6 issues.
I'm roughly following https://ef.readthedocs.org/en/latest/getting-started/aspnet5/existing-db.html#install-entity-framework
any ideas? thanks for looking.
from project.json:
...
"EntityFramework.Core": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final"
},
"frameworks": {
"dnxcore50": { }
},
...
<C:\git\zeus\OrdersService\src\OrdersService>dnx ef dbcontext scaffold "Server=dev3;Database=db3;Trusted_Connection=True;" EntityFramework.MicrosoftSqlServer --outputDir Models
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary```2.get_Item(TKey key) at Microsoft.Data.Entity.Scaffolding.SqlServerDatabaseModelFactory.GetIndexes() at Microsoft.Data.Entity.Scaffolding.SqlServerDatabaseModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet) at Microsoft.Data.Entity.Scaffolding.RelationalScaffoldingModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet) at Microsoft.Data.Entity.Scaffolding.SqlServerScaffoldingModelFactory.Create(String connectionString, TableSelectionSet tableSelectionSet) at Microsoft.Data.Entity.Scaffolding.Internal.ReverseEngineeringGenerator.GetMetadataModel(ReverseEngineeringConfiguration configuration) at Microsoft.Data.Entity.Scaffolding.Internal.ReverseEngineeringGenerator.GenerateAsync(ReverseEngineeringConfiguration configuration, CancellationToken cancellationToken) at Microsoft.Data.Entity.Design.DatabaseOperations.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, List
1 schemas, List1 tables, Boolean useDataAnnotations, CancellationToken cancellationToken) at Microsoft.Data.Entity.Commands.Program.Executor.<>c__DisplayClass11_0.<<ReverseEngineerAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Data.Entity.Commands.Program.Executor.<ExecuteAsync>d__13.MoveNext() The given key was not present in the dictionary.
The text was updated successfully, but these errors were encountered: