.net - Can I implement Entity Framework 5 TPT on Windows XP? -


examples of ef5 table per type have found, such this one use [table("tablename")] attribute mark class defining table.

when add attribute errors:

error   1   type or namespace name 'tableattribute' not found (are missing using directive or assembly reference?)    e:\eshared\syrius6\syrius_syrius\sbd.syrius.domainclasses\classes.cs    599 6   domainclasses error   2   type or namespace name 'tableattribute' not found (are missing using directive or assembly reference?)    e:\eshared\syrius6\syrius_syrius\sbd.syrius.domainclasses\classes.cs    599 6   domainclasses 

i have line

 using system.componentmodel.dataannotations; 

in namespace

and using framework 4 because want app run on windows xp.

[update] had @ link flagged possible duplicate here, , consequence added reference system.data.linq , using system.data.linq

the error messages

 error  1   type or namespace name 'tableattribute' not found (are missing using directive or assembly reference?)    e:\eshared\syrius6\syrius_syrius\sbd.syrius.domainclasses\classes.cs    599 6   domainclasses error   2   using generic type 'system.data.linq.table<tentity>' requires 1 type arguments  e:\eshared\syrius6\syrius_syrius\sbd.syrius.domainclasses\classes.cs    599 6   domainclasses 

importantly, want code work on windows xp , , second answer possible duplicate requires framework 4.5

[update] code follows;

namespace sbd.syrius.domainclasses {  using system;  using system.collections.generic;  using system.componentmodel;  using system.componentmodel.dataannotations;  using system.data.linq;   [table("product")]  public class product : loggedentity  {      [required]     public string buyunitmeasure { get; set; }     [required]     public decimal buyunitquantity { get; set; }     [required]     public string code { get; set; }     [required]     public string name { get; set; }     [required]     public string sellunitmeasure { get; set; }     [required]     public decimal sellunitquantity { get; set; }      public virtual template template { get; set; }     [required]     public string unitmeasure { get; set; }       public override string tostring()     {         return !string.isnullorempty(this.name) ? this.name : "products";     }  }   public abstract class loggedentity {     public int id { get; set; }     public guid rowid { get; set; }      [concurrencycheck]     public int rowversionid { get; set; }      public int sourcesitenumber { get; set; }   } } 

[update]

i corrected using using system.data.linq.mapping;

now error

 system.data.linq.mapping.tableattribute' not contain constructor takes 1 arguments   

[update]

i looked @ not accepted answer suggested duplicate question. use system.componentmodel.dataannotations requires framework 4.5 , don't think can use because wont run on windows xp, , need run on xp.

[update] here screen in manage nuget packages

here reference in project

i developing on windows 7 application needs run on xp. see example trying follow here again uses framework 4.1 fluent

my question can use tpt on ef5 run on windows xp? if so, how?

first of all, remove system.data.linq namespace , don't use tableattribute there. linq-to-sql , not entity framework.

between version 4.1 , 5.0 of entity framework table attribute (among others) has been moved around bit between namespaces and assemblies:

depending on version can find attribute @ follwing places:

entity framework 4.1 4.3 , target framework .net 4.0

  • add reference entityframework.dll assembly project
  • add using system.componentmodel.dataannotations; code file

entity framework 5.0 , target framework .net 4.0 (this combination called entity framework 4.4)

  • add reference entityframework.dll assembly project
  • add using system.componentmodel.dataannotations.schema; code file

entity framework 5.0 , target framework .net 4.5

  • add reference system.componentmodel.dataannotations.dll assembly project
  • add using system.componentmodel.dataannotations.schema; code file

the tableattribute has kept old purpose , meaning in versions. it's correct 1 use tpt.

in situation want support windows xp use ef 5.0 need .net 4.0 target framework. correct tableattribute have do:

  • add reference entityframework.dll assembly project (most have already)
  • check if dll (right mouse -> properties) has version number 4.4. can potentially have wrong version (5.0) if downloaded nuget package while project targetted .net 4.5. , changed framework later .net 4.0. in case remove reference current entityframework.dll , add reference entityframework.dll assembly in path packages\entityframework.5.0.0\lib\net40 under solution folder
  • add using system.componentmodel.dataannotations.schema; code file

start last of these 3 points, maybe it's problem have append .schema using directive.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -