Question

I am trying to create Repository , Entity framework for Portable Class Library , when ever I try to Nuget EntityFramework

it is Failed to add reference to 'System.ComponentModel.DataAnnotations'. Please make sure that it is in the Global Assembly Cache.

Any Idea to resolve this for EF

Compatible EF package for Portable Library

Was it helpful?

Solution 3

EF7 has PCL , so if any one planning to use PCL can use early version of EF7 or VS2014

OTHER TIPS

You can use fluent Api, don't use data annotations and attributes in the model class.

Example: for defining a primary key; instead of using [Key] tag, use:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);
    modelBuilder.Entity<Record>().HasKey<int>(s => s.ID);
}

Prior to Visual Studio Update 2 you could create a PCL project that targets .Net 4 or .Net 4.5 and Windows 8, which would allow you to install the EntityFramework nuget package. After this update you cannot target Windows 8 without Windows Phone 8.1 being automatically targeted.

This auto targeting of Windows Phone seems to prevent adding EF package to PCL that targets Windows 8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top