Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
生成意外格式的C#实体框架6外键约束_C#_Mysql_Entity Framework_Foreign Keys - Fatal编程技术网

生成意外格式的C#实体框架6外键约束

生成意外格式的C#实体框架6外键约束,c#,mysql,entity-framework,foreign-keys,C#,Mysql,Entity Framework,Foreign Keys,我添加了2个包含外键的型号。在分析生成的查询时,EF以意外的方式生成约束名称 public class SnapAppSession { [Key] public int Id { get; set; } [MaxLength(36)] public string AppUploadSessionHandle { get; set; } [ForeignKey("User")] public string UserId { get; se

我添加了2个包含外键的型号。在分析生成的查询时,EF以意外的方式生成约束名称

  public class SnapAppSession
{
    [Key]
    public int Id { get; set; }


    [MaxLength(36)]
    public string AppUploadSessionHandle { get; set; }

    [ForeignKey("User")]
    public string UserId { get; set; }

    public DateTime CreatedOn { get; set; }


    public virtual ApplicationUser User { get; set; }


    public virtual ICollection<SnapAppSessionsBreakdown> Breakdown { get; set; }

}



public class SnapAppSessionsBreakdown
{
    [Key]
    public int Id { get; set; }


    [ForeignKey("SnapAppSession")]
    public int SnapAppSessionId { get; set; }

    public string FileName { get; set; }

    public virtual SnapAppSession SnapAppSession { get; set; }


}
SnapAppSessionsBreakdowns-(FK_4342715c7ab44a358f96e48e0cce132e的意外名称):


为什么生成的名称是随机的?如果有任何不同,我将使用MYSQL EF。

此行为与生成的FK名称长度超过中所述的特定限制有关。

我认为这与生成的FK名称长度超过特定限制有关。
alter table `SnapAppSessions` add constraint `FK_SnapAppSessions_AspNetUsers_UserId`  foreign key (`UserId`) references `AspNetUsers` ( `Id`) 
alter table `SnapAppSessionsBreakdowns` add constraint `FK_4342715c7ab44a358f96e48e0cce132e`  foreign key (`SnapAppSessionId`) references `SnapAppSessions` ( `Id`)