我有以下实体:
public class ProductInventory
{
/// <summary>Gets or sets the product inventory identifier.</summary>
/// <value>The product inventory identifier.</value>
public long ProductInventoryId { get; set; }
/// <summary>Gets or sets the name.</summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>Gets or sets the axis calibration.</summary>
/// <value>The axis calibration.</value>
public double AxisCalibration { get; set; }
/// <summary>Gets or sets the description.</summary>
/// <value>The description.</value>
public string Description { get; set; }
/// <summary>Gets or sets the create date.</summary>
/// <value>The create date.</value>
public DateTimeOffset CreateDate { get; set; }
}
我需要为Name创建一个非聚集索引,并包括以下属性:AxisCalibration,Description。
答案 0 :(得分:0)
您可以使用ForSqlServerInclude:
modelBuilder.Entity<ProductInventory>().HasIndex("Name").ForSqlServerInclude("AxisCalibration", "Description");
ForSqlServerInclude在最新的预览版本3.XXX中可以正常工作。