Visual Studio 2010 with MVC 4 - visual-studio-2010

I just downloaded and installed MVC 4 on VS 2010 Professional. I started a new project and here's the list of Errors that i got on my first build-
1.The type or namespace 'Infrastructure' does not exist in the namespace 'System.data.Entity'(Are you missing an assembly reference?)
2.Namespace 'schema' does not exist in namespace 'System.componentmodel.dataannotations'..
similar is the case with 'dbcontext','dbset','tablettribute','table','databasegeneratedattribute' .....
Please suggest what references do i need to include for these errors.?
How can i include the entity framework to my project as it says that it cannot be found?
This is the first time i am using ASP.NET MVC 4 with VS 2010.
I googled but didnt find the exact solution for this.
Please help!
regards

you don't have install Entity Framework thats y you got that type of error
you can solve this problem by do this
open Vs 2010
go to tools
select Library Package Manager
Go to Manage NUget Packages or Package Manager Console
if you use Package Manager Console type this command on console
Install-Package Entity-Framework
if you use Manage NUget Packages
Download EF5 and install it

Related

Hi, I'm trying to instal Nuget packagebut the following appear

This is the result, I tried many packages but all say the same.
I'm using Visual Studio 2019
Severity Code Description Project File Line Suppression State
Error Could not install package 'SQLitePCLRaw.core 2.0.4'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
As I'm new in this field I don't understand what it means,
Thanks for your help
You can see that this nuget package depends on the .net which means that it is used for C# projects.
From your description, you have installed this package on a C++ project. So the error happens.
I have a small test: install this package in C++ project which proves the root cause of the issue.
Suggestion
You should create a C# project and then you can install this nuget package on that.

Using ADO.NET's Entity Framework with visual studio 2010 and NuGet - what's really happening

I'll need to use ADO.NET EF for my next project so I started a tutorial but ended up with installing Entity Framework while my Project was open through Project -> Manage NuGet Packages and then decided to walk through the tutorial using another project so I closed the current one and on the next day I created new Console Project for the needs of this tutorial. However when I tried to add using System.Data.Entity; to my Program.cs it didn't recognize the Entity so I had to install again Entity Framework from NuGet which seems kind of strange to me.
Is this how it should be - installing the Entity Framework for every project that will use it or I can install it once and then add it as reference where needed or something like that like many other packages in .NET?
No, you shouldn't need to install Entity Framework for each project. Did you try adding a reference to the missing DLL? To do this, right-click your project in Solution Explorer and select Add Reference from the menu. You should be able to select System.Data.Entity from the .NET tab:

Installed the reference from NuGet but VS2010 cant find the namespace

I am quite new to C# and Visual Studio but I just downloaded the Facebook C# SDK from NuGet but when I try to use it using:
using Facebook;
visual studio says that it cannot find the namespace name. I checked my references list and Facebook is on the project's reference list.
I tried to follow the instructions from this post on code project.
http://www.codeproject.com/Articles/20032/Creating-a-simple-Facebook-Application-using-WPF
All the examples that I found so far online do not suggest for a problem of that nature.
any suggestions?
Sometimes some NuGet issues require to re-open the project with the referenced assembly to load it. This problem is not Facebook-specific.

Adding MOQ to a .NET 4.0 project is not possible

I want to add MOQ .net library to a .NET 4.0 project. I get an error message that I should convert the project to something smaller than 4.0. I need to use .NET 4.0 also because of other project dependencies.
How can I make MOQ work with a .NET 4.0 project in VS2010 ?
Make sure you have NuGet package manager installed (Tools/Extension Manager).
Right click on Solution Explorer/References, choose Manage NuGet Packages.
Type Moq in the search box.
Install and enjoy.
The latest version from Google Code (http://code.google.com/p/moq/), works in a .Net 4.0 project. I would just download the dll again.
Here is the download link: http://code.google.com/p/moq/downloads/detail?name=Moq.4.0.10827.Final.zip
The zip file at that location contains a .Net 4 folder. Use the dll : Moq.dll from the NET40 folder and everthing will work fine. Just do a normal Add Reference on the project.
I would check the version number and the Runtime veseion of the assembly you are trying to use. It should say:
Runtime Version: v4.0.20926
Version: 4.0.10827.0
For the sake of completeness, it may be worth pointing out that it is also possible to use the Visual Studio command line package manager tool:
1) Open the console in VS
View >> Other Windows >> Package Manager Console
2) Install Moq
Type Install-Package Moq at the prompt
Note: If your tests are in a separate project, make sure that you select that project in the project dropdown.
This will install the latest package available in NuGet, which should address your compatibility issue. See http://nuget.org/packages/moq.
Watch out that you're using .NET 4, rather than the .NET 4 Client Profile as your Target Framework. I had the same issue and that was the cause for me.

System.Web.Mvc missing error while building ASP.NET MVC 3 using NAnt

My MVC 3 project is building successfully in my development machine with Visual Studio 2010 + MVC 3. In the build server, VS2010 is not used and I've installed 'ASP.NET MVC 3 Tools Update'. I've also downloaded NAnt and used TortoiseSVN to checkout all the files except bin directories.
But while building using Nant default.build, I'm getting build error
'The type or namespace name 'Mvc' does not exist in the namespace
'System.Web'
(are you missing an assembly reference?). Same with 'Controller', 'ActionResult', 'GlobalFilterCollection' etc (type or namespace could not be found).
I can see System.Web.Mvc.dll in
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\
. What am I missing here? Why NAnt can't find this file? Is there no other way than copying the assembly files into local bin?
I had the same issue and wasn't able to locate the System.Web.MVC reference assembly.
Finally found out and it was located inside the following location.
Note if your VS was installed in C: (Sometimes the MVC is not in the defaul location which everybody talk about, i mean the "Reference Assemblies" folder located in the C: drive.
if its not there, it should definitely be in here:
Program files(x86) --> Microsoft ASP.NET --> ASP.NET MVC 2 --> Assemblies System.Web.Mvc.dll
Hope this one is helpful.
Here is my answer -
Best way is to use NuGet package manager.
Just update the below MVC package and it should work
Why is System.Web.Mvc not listed in Add References?
If you use NuGet packages, you need to update MVC package. This worked for me.
If you Installed MVC Package from NuGet packages. simply uninstall package and install it again.
It's work for me
Which version of msbuild are you using to build the web project?
Is the web project referencing a specific version of or file path to System.Web.Mvc.dll?
Download and install ASP.NET MVC 3:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=4211
According to: http://weblogs.asp.net/scottgu/archive/2011/05/03/asp-net-mvc-3-tools-update.aspx
"The ASP.NET MVC 3 Tools update only includes Visual Studio tooling improvements and default project template changes – it does not include any changes to the ASP.NET MVC 3 runtime binaries."

Resources