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

Running dnx ef dbcontext scaffold throws 'The given key was not present in the dictionary.' dnvm 1.0.0-rc1-final #4031

Closed
collintime opened this issue Dec 9, 2015 · 5 comments

Comments

@collintime
Copy link

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, List1 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.

@collintime
Copy link
Author

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.

@collintime
Copy link
Author

we removed all non-clustered indexes and the model generation was successful

@lajones
Copy link
Contributor

lajones commented Dec 14, 2015

Looks like a dupe of #3861 - fix was checked in with commit 454968a. But feel free to reopen if you are still experiencing it.

@cokobware
Copy link

I'm doing the same thing, and getting the same error.

Running "dnx --version" gives me:
Microsoft .NET Execution environment
Version: 1.0.0-rc1-16231
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 6.1
Runtime Id: win7-x86

Running "dnx ef --version" gives me:
Entity Framework Commands
7.0.0-rc1-16348

Am I doing something wrong, or do I need to update my tooling?

@lajones
Copy link
Contributor

lajones commented Mar 23, 2016

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.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants