Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a known issue with 4.3 and 4.3.1. (We found it too late to put the fix in 4.3.1.) Luckily there is a fairly simple way to change your code that should make it work.</p> <p>In a nutshell, you used to be able to make chained map calls on a single EntityConfiguration in 4.1. and 4.2. Something like this pattern:</p> <pre><code>modelBuilder.Entity&lt;Parent&gt;() .Map&lt;Foo&gt;(...) .Map&lt;Bar&gt;(...); </code></pre> <p>This doesn't work in 4.3 and instead you have to make each Map call on an EntityConfiguration for that entity. So a pattern something like this:</p> <pre><code>modelBuilder.Entity&lt;Foo&gt;() .Map&lt;Foo&gt;(...); modelBuilder.Entity&lt;Bar&gt;() .Map&lt;Bar&gt;(...); </code></pre> <p>Taking your case specifically, this should work:</p> <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity&lt;ParentClass&gt;() .ToTable("Parent"); modelBuilder.Entity&lt;Foo&gt;() .Map(m =&gt; { m.Requires("IsActive").HasValue(1); m.Requires("Type").HasValue("Foo"); }); modelBuilder.Entity&lt;Bar&gt;() .Map(m =&gt; { m.Requires("IsActive").HasValue(1); m.Requires("Type").HasValue("Bar"); }); } </code></pre> <p>(I've removed a few of the generic parameters since they aren't needed, but that's not important.)</p> <p>Doing this using explicit EntityConfigurations you would use something like this:</p> <pre><code>public class ParentConfiguration : EntityTypeConfiguration&lt;ParentClass&gt; { public ParentConfiguration() { ToTable("Parent"); } } public class FooConfiguration : EntityTypeConfiguration&lt;Foo&gt; { public FooConfiguration() { Map(m =&gt; { m.Requires("IsActive").HasValue(1); m.Requires("Type").HasValue("Foo"); }); } } public class BarConfiguration : EntityTypeConfiguration&lt;Bar&gt; { public BarConfiguration() { Map(m =&gt; { m.Requires("IsActive").HasValue(1); m.Requires("Type").HasValue("Bar"); }); } } </code></pre> <p>And then</p> <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Configurations .Add(new ParentConfiguration()) .Add(new FooConfiguration()) .Add(new BarConfiguration()); } </code></pre> <p>We plan to fix this in 5.0.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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