ASP.NET MVC + Entity Framework: The type or namespace name 'Entity' does not exist in the namespace 'System.Data'

Hi Fourm.

Hi have a problem whiel I'm trying to  access to an entity object within a ViewPage:

The problem si that when I import Syste.Data.Entity:

<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.Entity" %>

I get this error:

 Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

Source Error:

Line 5:  <%@ Import Namespace = "UmlModels.Site.EntityFramework" %>
Line 6:  <%@ Import Namespace = "System.Data" %>
Line 7:  <%@ Import Namespace = "System.Data.Entity" %>
Line 8: 
Line 9:  <html xmlns="http://www.w3.org/1999/xhtml" >

 

I have manualy added System.Data.Entity reference to the project where is th asp.net mvc and I dont get any error when I import System.Data.Entity and use the entity in the Controller.

What I am skipping?

Thanks in advance.

 


--
http://www.vic-fontaine.com/
0
crosscompiler
2/7/2009 9:36:22 PM
asp.net.3.5-extensions-preview 378 articles. 0 followers. Follow

5 Replies
5050 Views

Similar Articles

[PageSpeed] 29

 

why don't you add them as following in code behind

using System.Data;

using System.Data.Entity;


If you cannot make thing good m make it looks like good

--------------------------------------------------
Always remember to click “Mark as Answer” on the post that helps you. Thank you!

0
ms_soft89
2/7/2009 9:52:15 PM

 I did, but still doesn't work Sad


--
http://www.vic-fontaine.com/
0
crosscompiler
2/8/2009 10:15:42 AM

 And if I remove the importos from the view.aspx and I add them only to the code behind, I get this error:

 

 Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c56sdf089'.

 


--
http://www.vic-fontaine.com/
0
crosscompiler
2/8/2009 10:19:23 AM

 Well.

 I moved the code to the code behind and I add a literal so I dont have to use the entity object on the view.

 It works and actually it's better to split the code from the view, so for me is SOLVED.

 Any way, the problem is there. Is very extrange that when you  import:

<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.Entity" %>

Says:"The type or namespace name 'Entity' does not exist in the namespace 'System.Data' "

 Why is trying to find Entity in System.Data? Instead of System.Data.Entity? I tried also with changing the order but doesn't work.


--
http://www.vic-fontaine.com/
0
crosscompiler
2/9/2009 6:35:38 PM

I had the same problem.

Searching in Google I found the solution in:  http://www.jfarrell.net/2008/10/tip-1-understanding-cryptic-mvc-errors.html

We need to add this line in our Web.Config:

<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

This worked for me! 

0
gporras
2/24/2009 3:32:29 AM
Reply:

Similar Artilces:

The type or namespace name 'SqlServer' does not exist in the namespace 'System.Data'
Hi, I have created a .net class library and i include the namespace : using System.Data.SqlServer but when i build my .net class library i get the folowing error: The type or namespace name 'SqlServer' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)    your help is highly appreciated Best regards System.Data.SqlClient not System.Data.SqlServerArticles and news on ASP/ASP.NETASPCode.net Thank you for the support I am Creating a Trigger using Managed Code in SQL Server so i create a class contains the following: using Syst...

The type or namespace name 'OracleClient' does not exist in the class or namespace 'System.Data'
I am using notepad to code my ASP.NET pages. Line 3: using System.Data.OleDb; Line 4: using System.Web; Line 5: using System.Data.OracleClient; Line 6: Line 7: public class OConn .. .. .. Source File: c:\inetpub\wwwroot\Oracle8.cs Line: 5 I know if I precompile the *.dll in my *.aspx page, it will work (<%@ Page language="c#" CompilerOptions=/R:"C:\WINNT\Microsoft.NET\Framework\v2.0.40607\System.Data.OracleClient.dll" Debug="true"%>). But i do not know the equivalent solution to implement in a *.cs file. Please ...

The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
 Hi everybody,I have a Web app project that uses Linq. I am receiving the following error:The type or namespace name 'Linq' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)in the line:using System.Data.Linq;The reference points to the correct file and in other projects everything is fine. the projects builds successfully and gives this error right after that.If someone has an idea what is happening or some previous experience with such an error - please.Thank you in advance.  Bulgaria Did you install Linq on the server? Jef...

Error "CS0234: The type or namespace name 'Data' does not exist in the namespace 'System'"
Dear all,the following web site ran for months without troubles http://www.fotovoltaico.sanzeno.org/StoricoRS.aspxSuddenly yesterday I started getting the error you can see switching to that site. I am really getting crazy wondering what happened, but I have no idea. Do you have any suggestion? Thank you in advancePierluigi ...

The type or namespace name 'HttpContext' does not exist in the namespace 'System.Web'
Hi thereI've created a wee class library with which to create a dll used by my web app. A class in the library needs to use System.Web.HttpContext.Current.Server.MapPath in order to get the physical location of a file regardless of where the application currently is.When I'm coding the class, Intellisense tells me that System.Web only has three members: AspNetHostingPermissionAspNetHostingPermissionAttributeAspNetHostingPermissionLevelI ignore it and type in the rest of the 'MapPath' stuff, but when I build the library I get the error I've used as the title of this thread...

The type or namespace name 'Configuration' does not exist in the namespace 'System.Web'
Hi,  I'm trying to use the the System.Web.Configuration namespace but keep getting this error:   The type or namespace name 'Configuration' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)   Do you have any idea what could be the reason? Hi,You need to add System.Configuration DLL via "Add Reference" dialog box. Right click References and select Add Reference, then select System.Configuration under the .NET tab.Hope this helps,Vivek Social Networking Platform in ASP.NET || Join now: CodeASP.NET Community...

The type or namespace name 'ScriptManager' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?)
Hello, I am trying to add ASP.NET AJAX functionality to an existing project. Here's what I did: I have downloaded and installed the AJAX executable from here: http://ajax.asp.net/ I have done an iisreset I have opened my existing project and modified the Web.config using this guide: http://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx I opened my MasterPage and I added <asp:ScriptManager ID="ScriptManager1" runat="server" /> just below the form-tag Whenever I try to build, I get this error: Error 36 The type or namespace name 'ScriptManager' does not exist in the nam...

CS0234: The type or namespace name 'Windows' does not exist in the class or namespace 'System' (are you missing an assembly reference?)
Anyone get this, i added system.windows.form to my references in my project and still get this... CS0234: The type or namespace name 'Windows' does not exist in the class or namespace 'System' (are you missing an assembly reference?) Line 3: using System.Collections; Line 4: using System.ComponentModel; Line 5: using System.Windows.Forms; //ERROR Line 6: using System.Data; Line 7: You're compiling from the command line, right? You have to add a reference to the System.Windows.Forms.dll to the compile line, using the /r switch. Eno...

CS0234: The type or namespace name 'Windows' does not exist in the class or namespace 'System' (are you missing an assembly reference?) #2
I included the <%@ import Namespace="System.Windows" %> directive in the code file, but for some reason I'm getting this error. I know it's an issue of assembly referencing and I can solve this in VS.NET but I don't know how to reference it right in WebMatrix. Is it true that all I have to do is include the above aforementioned directive in my code page and I'm set to go or do I need to do some configuration work? Help... Anyone... Please......

The type or namespace name 'ListView' does not exist in the namespace 'System.Web.UI.WebControls' (are you missing an assembly reference?) error
I have created a ASPX form with a ListView See below: <form id="form1" runat="server"> <asp:ListView id="ProductList" runat="server" > <LayoutTemplate> <h3>Product Listing</h3> <blockquote> <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder> </blockquote> </LayoutTemplate> <ItemSeparatorTemplate> <hr /> </ItemSeparatorTemplate> <ItemTemplate> <h4><%#Eval("ProductName")%> (<%# Eval("Catego...

Error 1 The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\asse
Once I build project. I encounter this error. Does someone experience this error?Error    1    The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll'    D:\Source Code\Linq_Lesson5\Default.aspx    1    1    D:\Source Code\Linq_Lesson5\  It appears tha...

Compiler Error: CS0234: The type or namespace name 'DataAccessHelper' does not exist in the namespace 'BCC'
Hi All,I'm new to ASP.NET and trying to create a Database application with MS Visual Web Dev 2005. In my project, I wrote a generic abstract class called DataAccessHelper.cs under App_Code folder which handles all the Database related work, so all my WebForm classes can inherit from itand consume its functions. Inside the VWD, when I press F5, it launches the browser with http://localhost:2739 and everything shows up as expected. However, when I try to access it through a regular port 80, I get the followingerror:*********************************************Compiler Error Message: CS0234: T...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

The type or namespace name 'Core' does not exist in the namespace 'YASUTech.QRDN.WebEditor' (are you missing an assembly reference?)
Hi,I am getting the following error message - "The type or namespace name 'Core' does not exist in the namespace 'YASUTech.QRDN.WebEditor' (are you missing an assembly reference?) " - when I try to build the web application I had migrated from VS2003 to VS2005.--------------------------------------- In the web application i had created using 1.1 Framework I had created a folder - "Core" - which contained 2 web pages and one class file.The following occured when I migrated by making use of the Conversion Wizard - 1. A folder "Core" was create...

[Microsoft.Web.Script.Services.ScriptService()]
Hi I'm trying to use the [Microsoft.Web.Script.Services.ScriptService()]  in my web service, but when I compile I receive the following error message: Error 1 The type or namespace name 'Web' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) Any suggestions how to fix this problem? Thanks in advance! RegardsEdward Hi, the correct namespace is System.Web.Script.Services.Alessandro Gallo | Blog | My book: ASP.NET AJAX In Action If like me and you watched Joe Stagners terrific video "How Do I: Make Client-Side Network Callbac...

Web resources about - ASP.NET MVC + Entity Framework: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' - asp.net.3.5-extensions-preview

Resources last updated: 1/21/2016 11:30:55 PM