c# - EF CodeFirst THT - Column 'Id' specified as part of this MSL does not exist in MetaDataWorkspace -


i'm using 'table-per-type' hierarchy in code-first project (ef5). derived classes override default primary-key name identify relationship database point of view, so:

/* change primary keys chair.productid , table.productid */ modelbuilder.entity<chair>()     .property(x => x.id)     .hascolumnname("productid");  modelbuilder.entity<table>()     .property(x => x.id)     .hascolumnname("productid"); 

using following classes example:

[table("product")] public class product {    public int id {get; set;}     /* generic product properties */ }  [table("chair")] public class chair : product {      /* specific chair properties */ }  [table("table")] public class table : product {      public virtual icollection<chair> chairs {get; set;}       /* specific table properties */ } 

which causes following error on property table.chairs: column 'id' specified part of msl not exist in metadataworkspace.

which kinda understand ef didn't see pk of chair product changed.. (and still assumes it's called 'id') can't figure out how instruct ef use alternate key.

thx,

ps. yes know, if don't change names of pk's works... can done using ef fluent api?

this bug of edmx model generator in visual studio.

to solve do:

  • remove particular table ef.
  • save ef , restart visual studio
  • add particular table model again
  • save , compile

i have visual studio 2015 udpate 3


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -