C# 实体框架:在搭建脚手架时删除两个方向导航
当我用实体框架核心构建数据库时,如何防止双向属性?我只想允许单向导航。是否有命令行scaffold参数 在Product类中,我要删除此属性C# 实体框架:在搭建脚手架时删除两个方向导航,c#,.net,entity-framework,.net-core,entity-framework-core,C#,.net,Entity Framework,.net Core,Entity Framework Core,当我用实体框架核心构建数据库时,如何防止双向属性?我只想允许单向导航。是否有命令行scaffold参数 在Product类中,我要删除此属性 public virtual ICollection<CustomerTransaction> CustomerTransaction { get; set; } 实体框架: public partial class CustomerTransaction { public int CustomerTransactionId { ge
public virtual ICollection<CustomerTransaction> CustomerTransaction { get; set; }
实体框架:
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<CustomerTransaction>();
}
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal? Amount { get; set; }
// REMOVE THIS LINE
public virtual ICollection<CustomerTransaction> CustomerTransaction { get; set; }
}
不是这样,
storeDbContext.Product.Include(c => c.CustomerTransaction).ToListAsync()
使用EF Core 2.2,@GAltelino我有1000多个表,正在寻找自动化的方法来实现这一点,thankshi@GertArnold我想要这些属性,但只想要一种方式,这说明它应该是单向的、域驱动的设计,hi@GertArnold我想要集合属性,只需要一种方式,这只是公司的要求,thankswell我们将数据层映射为非常接近domain layerhi@Pac0只是好奇Microsoft是否有Entity Framework scaffold命令行参数,而不是创建自定义正则表达式,谢谢
storeDbContext.CustomerTransaction.Include(c => c.Product).ToListAsync()
storeDbContext.Product.Include(c => c.CustomerTransaction).ToListAsync()