Frage

I am building a .Net 4.0 web project on Server 2012 with .Net 4.5 installed. I am using Psake under TeamCity and am getting CS0246 saying NotMapped could not be found, along with CS0433 saying it has found two DLLs for DataAnnotations.

The class looks like this:

using System.ComponentModel.DataAnnotations.Schema;
public abstract class Order
{
   [NotMapped]
   public decimal TaxPercentage { get; set; }
}

The full errors are:

Ordering\Order.cs(105,8): error CS0246: The type or namespace name 'NotMapped' could not be found (are you missing a using directive or an assembly reference?) [C:\TeamCity\buildAgent\work\71c853cb9b4c108\Code\Models\Model.csproj]
Ordering\Order.cs(105,8): error CS0433: The type 'System.ComponentModel.DataAnnotations.Schema.NotMappedAttribute' exists in both 'c:\TeamCity\buildAgent\work\71c853cb9b4c108\Code\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll' and 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll' [C:\TeamCity\buildAgent\work\71c853cb9b4c108\Code\Models\Model.csproj]

The build works fine under Windows 8 using just Psake and not TeamCity. Any ideas how to resolve this?

Update: I've made a smaller test project and this builds fine on 2012. Looks like there's something weird with my main project.

War es hilfreich?

Lösung

Turns out System.ComponentModel.DataAnnotations shipped in EF 4.4, whereas they are in a separate assembly for EF 5.0. I had a mix of EF references in my projects which I have now rebuilt - all to use EF 5 and it's fixed the problem.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top