Note that there are some explanatory texts on larger screens.

plurals
  1. POEF5 code first - You cannot use Ignore method on the property
    primarykey
    data
    text
    <p>This question has been asked all over the place, but the SUPPOSED workaround on <a href="http://entityframework.codeplex.com/workitem/481" rel="nofollow">CodePlex</a> does not work.</p> <p>I'm hoping someone has some updated information.</p> <p>I have an EF5 Code First project where I have dozens of entities directly derived from an abstract base class. After creating some new entities that are derived from a class derived from that base class, when my database is initially created I get the following error:</p> <pre><code>You cannot use Ignore method on the property 'DisplayString' on type 'Doctor' because this type inherits from the type 'Contact' where this property is mapped. To exclude this property from your model, use NotMappedAttribute or Ignore method on the base type. </code></pre> <p>Here's my classes:</p> <pre><code>public abstract class AbsoluteBaseClass { [NotMapped] public abstract string DisplayString { get; set; } ... } public class Contact : AbsoluteBaseClass { [NotMapped] public override string DisplayString { get { return string.Format("{0} {1}", FirstName, LastName); } set { throw new System.NotImplementedException(); } } ... } public class Doctor : Contact { ... } </code></pre> <p>I have other cases like this (class derived from a class derived from the base) and I've got things working, but adding these new classes broke things again.</p> <p>I've also tried add .Ignore directives (derived class before base) in OnModelCreating and that does not make any difference either.</p> <pre><code> modelBuilder.Entity&lt;Doctor&gt;().Ignore(p =&gt; p.DisplayString); modelBuilder.Entity&lt;Contact&gt;().Ignore(p =&gt; p.DisplayString); </code></pre> <p>I have several cases where I have entities derived from AbsoluteBaseClass and most times things work, but then I would add another derived class and things would break again. There appears to be no rhyme or reason to this.</p> <p>I'd REALLY appreciate some advice on how I can definitively get this to work as I add classes. There appears mention around of a fix applied to the EF5 source,then you build the source. Has anyone tried that and got it to work?</p> <p>Thanks for any advice! Corey.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload