Please disable your adblock and script blockers to view this page
 

The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) Asp.Net MVC error solution

Introduction: In previous Asp.Net MVC articles i explained What is Asp.Net MVC? Its work flow,goals and advantages and Difference between Asp.Net Webforms and Asp.Net MVC and Asp.Net MVC 4 application to Create,Read,Update,Delete and Search functionality using Razor view engine and Entity Framework . 
In this article i am going to explain How to solve the following Asp.net MVC errors:
  • The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
  • The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)
Implementation: Follow the steps mentioned below to resolve the error:

1.       Select the Project Name in Solution Explorer.
2.       From the Tools Menu of visual studio, select Library Package Manager which has a sub-menu.
3.       From the sub-menu select Package Manager Console.

4.       Package manager console will open in the bottom of the visual studio screen
5.       At the Package manager console prompt type install-package EntityFramework and then hit enter. (Note: Internet Connection is required while running this command because it downloads the EntityFramework package.
6.       It will download and install the required Entity Framework.

After successfully completing the above steps right click on your project in Solution Explorer and Select Add reference -> Select the .NET tab and then scroll down and select System.Data.Entity and Click Ok button. It will add the reference of required Entity.

Now you just need to add the reference
using System.Data.Entity;
 in the model class where you are facing error and the bug will be gone.

Now over to you:
" I hope you have got the way to resolve the errors and If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google+, Twitter, Linked in and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox . Stay tuned and stay connected for more technical updates."
Previous
Next Post »

6 comments

Click here for comments
Anonymous
admin
January 11, 2014 ×

Muito obrigado.

Reply
avatar
January 11, 2014 ×

Your welcome..stay connected and keep reading for more useful updates like this..:)

Reply
avatar
Anonymous
admin
November 15, 2014 ×

great

Reply
avatar
November 19, 2014 ×

Thanks for the appreciation..:)

Reply
avatar
Anonymous
admin
February 14, 2015 ×

THANK YOU!!

Reply
avatar
February 20, 2015 ×

Your welcome..stay connected for more useful updates..).

Reply
avatar

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily.. ConversionConversion EmoticonEmoticon