问题描述
我有这个实体类:
public class StatusCode
{
public const String ClassName = nameof(StatusCode);
[Key]
public Guid UniqueID { get; set; } // Primary Key
public Char Level { get; set; } // R=Root,C=Code Group,I=Item
public Guid CodeGroup { get; set; } // F Key - Which group of codes this code belongs to (self reference to this table)
public String Code { get; set; } // Public short form code,normal public use in tabular reports
public String FullName { get; set; } // Full public name,normal public stand alone display
public String Description { get; set; } // Description displayed to explain this code to the public,typically a full sentance
public String PublicRemarks { get; set; } // Longer public remark about this code,typically a few paragraphs
public String PrivateRemarks { get; set; } // Internal use only remark,for display to administrators about the usage of this code
public Boolean AvailableYesNo { get; set; } // Flag to show if this code is available for usage on new records
public DateTime AvailableFrom { get; set; } // Date time that this code is available for first use
public DateTime AvailableTo { get; set; } // Date time that this code is no longer available for use
}
通过这次迁移:
protected override void Up(MigrationBuilder migrationBuilder)
{
String lLogHdr = $"{ClassName}.{HCG_Misc.CallingMethodName()} ";
Console.WriteLine( $"{lLogHdr} - Start" );
migrationBuilder.CreateTable(
name: "StatusCode",columns: table => new
{
UniqueID = table.Column<Guid >( type: "uniqueidentifier",nullable: false ),Level = table.Column<string >( type: "nvarchar(1)",CodeGroup = table.Column<Guid >( type: "uniqueidentifier",Code = table.Column<string >( type: "nvarchar(450)",nullable: true ),FullName = table.Column<string >( type: "nvarchar(max)",Description = table.Column<string >( type: "nvarchar(max)",PublicRemarks = table.Column<string >( type: "nvarchar(max)",PrivateRemarks = table.Column<string >( type: "nvarchar(max)",AvailableYesNo = table.Column<bool >( type: "bit",AvailableFrom = table.Column<DateTime>( type: "datetime2",AvailableTo = table.Column<DateTime>( type: "datetime2",nullable: false )
},constraints: table => { table.PrimaryKey("PK_StatusCode_UniqueID",x => x.UniqueID);
});
migrationBuilder.CreateIndex( name: "Index_StatusCode_Code",table: "StatusCode",column: "Code" );
migrationBuilder.CreateIndex( name: "Index_StatusCode_CodeGroup",column: "CodeGroup" );
Console.WriteLine( $"{lLogHdr} - Complete" );
}
当我跑步时
PM> Update-Database
我得到了一个带有聚集主键索引的数据库表,这对于 GUID 索引来说太疯狂了。我需要做什么才能获得非聚集索引?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)