-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Unable to create an object of type 'MvcMovieContext' #7636
Comments
@msharps I'm not sure what you did wrong but that error is misleading. You might compare your code to the download to see what when wrong. |
You need to add an implementation of IDesignTimeDbContextFactory where the ApplicationDbContext is put (in my case it's in Data folder) |
@hoangpham0501 You do not have to add an implementation of The instructions in the tutorial are complete and correct. |
Maybe you should check it again :D I have followed this tutorial step by step and I got same error with msharps. So I added an implementation of IDesignTimeDbContextFactory and then it worked :D |
I'm getting exactly the same error running Dotnet version 2.1.202 |
As this tutorial is from 2016, I'd imagine it's quite feasible for something to have changed, so saying "The instructions in the tutorial are complete and correct." is quite a bold statement? |
@hoangpham0501 see https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?view=aspnetcore-2.1&tabs=aspnetcore2x#install-visual-studio-and-net-core You need the current .NET Core SDK |
@Rick-Anderson Upgrading the latest version of the .NET Core SDK does not make this problem go away. Also, following the tutorial to the T does not make the error go away. |
@jdmagic21 no you're right it is misleading, I even downloaded the latest from the website and it made no difference. What fixed it for me was to update the Nuget packages. Right click on your project in solution explorer and select manage Nuget packages, and update the ones that have a little blue arrow . Hope that fixes it for you! |
Make sure that your progam.cs file is correct. Use BuildWebHost(). |
Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments. |
Encountered the following error when executing "Add-Migration Rating":
Unable to create an object of type 'MvcMovieContext'. Add an implementation of 'IDesignTimeDbContextFactory<MvcMovieContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
Visiual Studio Community 2017 version 15.7.5
.NET Framework version 4.6.01590
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: