title: "The association has been severed but the relationship is either marked as 'Required' or is implicitly required..."
body: <p>I am getting the following error when trying to add a migration:</p>
  <pre><code>PS C:\Code\morpher.ru\Morpher.Database&gt; dotnet ef migrations add AddQazaqFeatures --startup-project=../Morpher.Database.Design
  Build started...
  Build succeeded.
  System.InvalidOperationException: The association between entity types 'Service' and 'Deployment' has been severed but the relationship is either m
  arked as 'Required' or is implicitly required because the foreign key is not nullable. If the dependent/child entity should be deleted when a requi
  red relationship is severed, then setup the relationship to use cascade deletes.  Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLoggin
  g' to see the key values.
     at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.HandleConceptualNulls(Boolean sensitiveLoggingEnabled, Boolean forc
  e, Boolean isCascadeDelete)
     at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.CascadeDelete(InternalEntityEntry entry, Boolean force, IEnumerable`1 fore
  ignKeys)
   ...
  </code></pre>
  <p>My code:</p>
  <pre class="lang-cs prettyprint-override"><code>    public class Deployment
      {
          public int Id { get; set; }
          public virtual Service Service { get; set; }
          public int ServiceId { get; set; }
          
          public string Host { get; set; }
          public short? Port { get; set; }
          public string BasePath { get; set; }
      }
  
      public class Service
      {
          public int Id { get; set; }
          public string Name { get; set; }
          
          public string UrlSlug { get; set; }
          
          public virtual ICollection&lt;Endpoint&gt; Endpoints { get; set; }
          
          public virtual ICollection&lt;Deployment&gt; Deployments { get; set; }
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Service&gt;().HasData(new Service
          {
              Name = &quot;Веб-сервис «Морфер»&quot;,
              UrlSlug = &quot;ws&quot;,
              Id = 1
          });
          modelBuilder.Entity&lt;Deployment&gt;().HasData(new Deployment
          {
              Host = &quot;ws3.morpher.ru&quot;,
              ServiceId = 1,
              Id = 1
          });
  
          modelBuilder.Entity&lt;Deployment&gt;(entity =&gt;
          {
              entity.Property(e =&gt; e.Host).IsRequired().HasMaxLength(256);
              entity.Property(e =&gt; e.BasePath).HasMaxLength(512);
  
              entity.HasOne(deployment =&gt; deployment.Service)
                  .WithMany(service =&gt; service.Deployments)
                  .HasForeignKey(d =&gt; d.ServiceId)
                  .OnDelete(DeleteBehavior.Restrict)
                  .HasConstraintName(&quot;FK_Deployments_Services&quot;);
          });
       }
  </code></pre>
  <p>There are numerous StackOverflow questions mentioning the same error (<a href="https://stackoverflow.com/q/66597610/1291717">1</a>, <a href="https://stackoverflow.com/q/59934765/1291717">2</a>, <a href="https://stackoverflow.com/q/46040886/1291717">3</a>), but they are mostly to do with removing entities while not having a CASCADE delete policy or a nullable foreign key.</p>
  <p>In my case, I am trying to add new rows and I don't see why it is considering the relationship 'severed'. Is setting ServiceId = 1 not enough?</p>