Entity Framework for Portable Class Library

c# entity-framework silverlight windows-8 windows-phone-8

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

1
7
4/5/2014 10:36:44 AM

Accepted Answer

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

3
11/12/2014 9:41:43 AM

Popular Answer

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);
}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow