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

Example: To enable reverse engineering from an existing database does not work #99

Closed
adayIvey opened this issue Dec 23, 2015 · 17 comments

Comments

@adayIvey
Copy link

https://github.com/aspnet/EntityFramework.Docs/blob/master/docs/getting-started/full-dotnet/existing-db.rst

The example to enable reverse engineering from an existing database does not work:
Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -connection "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;"

when I tried this is vs2015 I get

The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:19

  • Scaffold-DbContext <<<< -provider EntityFramework.MicrosoftSqlServer -connection "Server=sqldev\sqltest;Database=IveyCore;Trusted_Connection=True;"
    • CategoryInfo : ObjectNotFound: (Scaffold-DbContext:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException
@rowanmiller
Copy link
Contributor

Did you install the EntityFramework.Commands package? That is the package that brings in that command.

BTW, best to view the docs at http://docs.efproject.net/en/latest/ as they are RST. GitHub partially renders them as MarkDown... but you don't get all the content.

@adayIvey
Copy link
Author

Yes i did install the commands

Sent from my Samsung device

-------- Original message --------
From: Rowan Miller [email protected]
Date: 12-23-2015 4:15 PM (GMT-05:00)
To: "aspnet/EntityFramework.Docs" [email protected]
Cc: "Day, Andrew" [email protected]
Subject: Re: [EntityFramework.Docs] Example: To enable reverse engineering from an existing database does not work (#99)

Did you install the EntityFramework.Commands package? That is the package that brings in that command.

BTW, best to view the docs at http://docs.efproject.net/en/latest/ as they are RST. GitHub partially renders them as MarkDown... but you don't get all the content.

Reply to this email directly or view it on GitHubhttps://github.com//issues/99#issuecomment-166991023.

@rowanmiller
Copy link
Contributor

Couple more questions:

  • What type of project is this in?
  • Did you close and re-open Visual Studio (on occasion I have seen Package Manager Console get the wrong security policy, which prevents the commands from loading).

@adayIvey
Copy link
Author

I tried this in a class library and a console app.

Using the latest 4.x framework

Sent from my Samsung device

-------- Original message --------
From: Rowan Miller [email protected]
Date: 12-23-2015 6:24 PM (GMT-05:00)
To: "aspnet/EntityFramework.Docs" [email protected]
Cc: "Day, Andrew" [email protected]
Subject: Re: [EntityFramework.Docs] Example: To enable reverse engineering from an existing database does not work (#99)

Couple more questions:

  • What type of project is this in?
  • Did you close and re-open Visual Studio (on occasion I have seen Package Manager Console get the wrong security policy, which prevents the commands from loading).

Reply to this email directly or view it on GitHubhttps://github.com//issues/99#issuecomment-167008093.

@rowanmiller
Copy link
Contributor

For you, are the steps to reproduce as simple as:

  • File -> New -> Project...
    • Select .NET Framework 4.6.1 from dropdown
    • Windows -> Console Application
    • Click OK
  • Tools -> NuGet Package Manager -> Package Manager Console
    • Install-Package EntityFramework.MicrosoftSqlServer.Design -Pre (installs 7.0.0-rc1-final)
    • Install-Package EntityFramework.Commands -Pre (installs 7.0.0-rc1-final)
    • Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -connection "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;"

If so, there must be something specific to your installation. A couple of initial questions to help narrow things down:

  • Can you run Get-ExecutionPolicy in Package Manager Console and see what it returns. Sometimes when commands don't work it's because the execution policy gets set to Restricted.
  • What version of VS do you have? Help -> About Microsoft Visual Studio - the latest version would be 14.0.24720.00 Update 1.

Also just confirming that these are not ASP.NET 5 class libraries/console apps... since Package Manager Console commands do not work with those project types yet.

@adayIvey
Copy link
Author

I will try when i am back in the office in the new year.... thanks

Sent from my Samsung device

-------- Original message --------
From: Rowan Miller [email protected]
Date: 12-28-2015 3:03 PM (GMT-05:00)
To: "aspnet/EntityFramework.Docs" [email protected]
Cc: "Day, Andrew" [email protected]
Subject: Re: [EntityFramework.Docs] Example: To enable reverse engineering from an existing database does not work (#99)

For you, are the steps to reproduce as simple as:

  • File -> New -> Project...
  • Select .NET Framework 4.6.1 from dropdown
  • Windows -> Console Application
  • Click OK
  • Tools -> NuGet Package Manager -> Package Manager Console
  • Install-Package EntityFramework.MicrosoftSqlServer.Design -Pre (installs 7.0.0-rc1-final)
  • Install-Package EntityFramework.Commands -Pre (installs 7.0.0-rc1-final)
  • Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -connection "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;"

If so, there must be something specific to your installation. A couple of initial questions to help narrow things down:

  • Can you run Get-ExecutionPolicy in Package Manager Console and see what it returns. Sometimes when commands don't work it's because the execution policy gets set to Restricted.
  • What version of VS do you have? Help -> About Microsoft Visual Studio - the latest version would be 14.0.24720.00 Update 1.

Also just confirming that these are not ASP.NET 5 class libraries/console apps... since Package Manager Console commands do not work with those project types yet.

Reply to this email directly or view it on GitHubhttps://github.com//issues/99#issuecomment-167643390.

@AndyFraserABZ
Copy link

I am having exactly the same problems.
I have followed the steps above except that I am creating a WinForms application.
Get-Execution returns RemoteSigned,
I am using VS 2015 version 14.0.24720.00 Update 1.

The only thing of note is that on executing the Install-Package EntityFramework.Commands -Pre command, it shows a Red error "Cannot bind parameter 'FilterScript'..." but continues and eventually says "Successfully installed 'EntityFramework.Commands 7.0.0-rc1-final' to ".

Andy

@adayIvey
Copy link
Author

adayIvey commented Jan 4, 2016

Thanks for your help I am going to give this a try.

I just noticed that my PS Version is only 2.0 should I go to 3.0 for should I go to the latest and greatest.

From: Rowan Miller [mailto:[email protected]]
Sent: Monday, December 28, 2015 3:04 PM
To: aspnet/EntityFramework.Docs [email protected]
Cc: Day, Andrew [email protected]
Subject: Re: [EntityFramework.Docs] Example: To enable reverse engineering from an existing database does not work (#99)

For you, are the steps to reproduce as simple as:

  • File -> New -> Project...
  • Select .NET Framework 4.6.1 from dropdown
  • Windows -> Console Application
  • Click OK
  • Tools -> NuGet Package Manager -> Package Manager Console
  • Install-Package EntityFramework.MicrosoftSqlServer.Design -Pre (installs 7.0.0-rc1-final)
  • Install-Package EntityFramework.Commands -Pre (installs 7.0.0-rc1-final)
  • Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -connection "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;"

If so, there must be something specific to your installation. A couple of initial questions to help narrow things down:

  • Can you run Get-ExecutionPolicy in Package Manager Console and see what it returns. Sometimes when commands don't work it's because the execution policy gets set to Restricted.
  • What version of VS do you have? Help -> About Microsoft Visual Studio - the latest version would be 14.0.24720.00 Update 1.

Also just confirming that these are not ASP.NET 5 class libraries/console apps... since Package Manager Console commands do not work with those project types yet.


Reply to this email directly or view it on GitHubhttps://github.com//issues/99#issuecomment-167643390.

@adayIvey
Copy link
Author

adayIvey commented Jan 4, 2016

Update…

I installed PS v4 amd that looks to have fixed my issue.

But while running Scaffold-DbContext I got error ‘The given key was not present in the dictionary.’

This looks to be a known issue dotnet/efcore#3861
Do you know if there are plans for a rc2 or a work around for this issue?

From: Rowan Miller [mailto:[email protected]]
Sent: Monday, December 28, 2015 3:04 PM
To: aspnet/EntityFramework.Docs [email protected]
Cc: Day, Andrew [email protected]
Subject: Re: [EntityFramework.Docs] Example: To enable reverse engineering from an existing database does not work (#99)

For you, are the steps to reproduce as simple as:

  • File -> New -> Project...
  • Select .NET Framework 4.6.1 from dropdown
  • Windows -> Console Application
  • Click OK
  • Tools -> NuGet Package Manager -> Package Manager Console
  • Install-Package EntityFramework.MicrosoftSqlServer.Design -Pre (installs 7.0.0-rc1-final)
  • Install-Package EntityFramework.Commands -Pre (installs 7.0.0-rc1-final)
  • Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -connection "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;"

If so, there must be something specific to your installation. A couple of initial questions to help narrow things down:

  • Can you run Get-ExecutionPolicy in Package Manager Console and see what it returns. Sometimes when commands don't work it's because the execution policy gets set to Restricted.
  • What version of VS do you have? Help -> About Microsoft Visual Studio - the latest version would be 14.0.24720.00 Update 1.

Also just confirming that these are not ASP.NET 5 class libraries/console apps... since Package Manager Console commands do not work with those project types yet.


Reply to this email directly or view it on GitHubhttps://github.com//issues/99#issuecomment-167643390.

@rowanmiller
Copy link
Contributor

I just noticed that my PS Version is only 2.0 should I go to 3.0 for should I go to the latest and greatest.

I installed PS v4 and that looks to have fixed my issue.

@bricelam we do require PS 3.0 right?

@Aday12345 - Regarding #3861 that is fixed and will ship in RC2 (planned for next month). In the meantime you could get out nightly builds that include the fix https://www.myget.org/Gallery/aspnetvnext

@adayIvey
Copy link
Author

adayIvey commented Jan 4, 2016

Thanks for all your help

From: Rowan Miller [mailto:[email protected]]
Sent: Monday, January 04, 2016 1:32 PM
To: aspnet/EntityFramework.Docs [email protected]
Cc: Day, Andrew [email protected]
Subject: Re: [EntityFramework.Docs] Example: To enable reverse engineering from an existing database does not work (#99)

I just noticed that my PS Version is only 2.0 should I go to 3.0 for should I go to the latest and greatest.

I installed PS v4 and that looks to have fixed my issue.

@bricelamhttps://github.com/bricelam we do require PS 3.0 right?

@Aday12345https://github.com/aday12345 - Regarding dotnet/efcore#3861 that is fixed and will ship in RC2 (planned for next month). In the meantime you could get out nightly builds that include the fix https://www.myget.org/Gallery/aspnetvnext


Reply to this email directly or view it on GitHubhttps://github.com//issues/99#issuecomment-168761234.

@AndyFraserABZ
Copy link

Yes, upgraded to PS4 and all seems to be fine now :-)
Many thanks.

Andy

@rowanmiller
Copy link
Contributor

Great - I have #103 our for review to add this as a pre-requisite

@rowanmiller
Copy link
Contributor

Thanks all for your work getting to the bottom of this one

@bricelam
Copy link
Contributor

bricelam commented Jan 4, 2016

we do require PS 3.0 right?

Yes, it's required by our module. Our module should fail to load without it; I wonder if the error is getting swallowed/hidden by NuGet...

@adayIvey
Copy link
Author

do you know when we will see RC2????

@bricelam
Copy link
Contributor

@Aday12345 No, but when we do, it'll be posted here.

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