Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
the type or namespace name DbContext could not be found( are you missing a user directive or assembly reference?) Why?

but i added the reference using- using System.Data.Entity; && System.Data; Namespaces
but still getting the same when working with entity framework why?

What i have tried?

i have rebuild and clean the solution but still getting the same. how to get rid of that error thankyou.

the code is below:(where i am getting the error)

C#
using System.Data.Entity;
using System.Data;
namespace EntityFramework
{
    public class EmployeeDBContext : DbContext  //here DbContext is displaying with red squiggle.//
    {
        public

    }
}


thanks in advance.
Posted
Updated 2-Oct-20 4:51am

You must add the Entity Framework to your solution.

Tools -> NuGet Package Manager -> Manage NuGet Packages for solution.
In Search Online enter "Entity Framework"
 
Share this answer
 
Comments
raxhemanth 16-Dec-14 10:54am    
Thankyou it's workig
TheRealSteveJudge 16-Dec-14 11:01am    
You're welcome!
"Using" has nothing to do with adding references. It is related to namespaces, which is a very different thing, and is merely a way to shorten down fully-qualified type names, by omitting the namespace part from them, fully or partially. You could just use full type name instead. Adding "using" doesn't add anything and does not change any behavior.

Referencing and assembly means modification of the assembly your compile; its relative path name of strong name gets into your assembly. It is done via a command-line key of a compiler. In Visual Studio and other similar IDE, this is done by adding a reference via the Solution Explorer. Locate the node "References" of your project. Please see:
http://msdn.microsoft.com/en-us/library/wkze6zky.aspx[^],
http://msdn.microsoft.com/en-us/library/8wxf689z%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/hk5f40ct%28v=vs.90%29.aspx[^].

See also: http://msdn.microsoft.com/en-us/library/sf0df423.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900