Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting compilation errors in a new MVC4 project?

I haven't been able to find an answer to this and have been scouring the internet all weekend, so I was hoping maybe you could help me out with this.

When using Visual Studio 2012, I create a new MVC4 Web Application Project and get some compilation errors.

Here is my problem:

  1. I create a new MVC4 Web Application using Visual Studio 2012, I select Internet Application and set it to use RAZOR Engine.

  2. I go to Application Properties and under the Application Tab I change Target Framework from .NET Framework 4.5 to .NET Framework 4.

  3. The build produces the following errors:

    Error 1 The type name 'TableAttribute' could not be found. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly. c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 21 6 MvcApplication1

    Error 2 The type or namespace name 'Table' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 21 6 MvcApplication1

    Error 3 The type or namespace name 'DatabaseGeneratedAttributeAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 25 10 MvcApplication1

    Error 4 The type name 'DatabaseGeneratedAttribute' could not be found. This type has been forwarded to assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly. c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 25 10 MvcApplication1

    Error 5 The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 54 10 MvcApplication1

    Error 6 The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 54 10 MvcApplication1

    Error 7 The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 87 10 MvcApplication1

    Error 8 The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) c:\users\saad\documents\visual studio 2012\Projects\MvcApplication1\MvcApplication1\Models\AccountModels.cs 87 10 MvcApplication1

like image 306
ComputerG33k Avatar asked Sep 30 '12 21:09

ComputerG33k


1 Answers

Simply Reinstall EntityFramework:

  1. Go to Package Manager Console
  2. Uninstall-Package entityframework
  3. Install-Package entityframework

that is it the error should go away!

like image 70
Stacker Avatar answered Oct 22 '22 13:10

Stacker