title: Entity Framework: Remove Both Directional Navigation when Scaffolding
body: <p>When I scaffold a database with Entity Framework Core, how do I prevent bidirectional properties ? I only want to allow 1 way unidirectional navigation. Is there a command line scaffold parameter?</p>
  
  <p>In Product Class,I want to remove this property</p>
  
  <pre><code>public virtual ICollection&lt;CustomerTransaction&gt; CustomerTransaction { get; set; }
  </code></pre>
  
  <p>Basically only Customer Transaction should have Navigation, since it has the actual Foreign Key. Want to remove last line, and have similarly 1000+ table entities like this. Need EF scaffold command line parameter or automation (maybe with Regex or other tool).</p>
  
  <p><strong>Database:</strong> </p>
  
  <pre><code>create table dbo.CustomerTransaction(
      CustomerTransactionId int NOT NULL,
      ProductId int NULL,
      Quantity int NULL,
      CustomerLastName varchar(255) NULL,
      constraint PK_CustomerTransactionId primary key clustered (CustomerTransactionId ASC))
  
  alter table dbo.CustomerTransaction add constraint fk_CustomerTransaction_Product_ProductId FOREIGN KEY(ProductId) REFERENCES dbo.Product (ProductId)
  </code></pre>
  
  <p><strong>Entity Framework:</strong></p>
  
  <pre><code>public partial class CustomerTransaction
  {
      public int CustomerTransactionId { get; set; }
      public int? ProductId { get; set; }
      public int? Quantity { get; set; }
      public string CustomerLastName { get; set; }
  
      //Keep this line since it has the foreign key
      public virtual Product Product { get; set; }
  }
  
  
  public partial class Product
  {
      public Product()
      {
          CustomerTransaction = new HashSet&lt;CustomerTransaction&gt;();
      }
  
      public int ProductId { get; set; }
      public string ProductName { get; set; }
      public decimal? Amount { get; set; }
  
      // REMOVE THIS LINE
      public virtual ICollection&lt;CustomerTransaction&gt; CustomerTransaction { get; set; }
  }
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <p>Only want this way available, </p>
  
  <pre><code>storeDbContext.CustomerTransaction.Include(c =&gt; c.Product).ToListAsync()
  </code></pre>
  
  <p>Not this way,</p>
  
  <pre><code>storeDbContext.Product.Include(c =&gt; c.CustomerTransaction).ToListAsync()
  </code></pre>
  
  <p>Using EF Core 2.2,</p>