Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.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# 实体框架外键错误,删除错误_C#_Mysql_Entity Framework - Fatal编程技术网

C# 实体框架外键错误,删除错误

C# 实体框架外键错误,删除错误,c#,mysql,entity-framework,C#,Mysql,Entity Framework,{"操作失败:无法更改关系,因为一个或多个外键属性不可为null。更改关系时,相关外键属性设置为null值。如果外键不支持null值,则必须定义新关系,并且必须分配外键属性已删除另一个非空值,或者必须删除不相关的对象。“} 公共部分类子类 { public int childID{get;set;} 公共int父ID{get;set;} 公共虚拟父CorrectionGroup{get;set;} 公共类父类:EntityTypeConfiguration { 公父() { //主键 this.

{"操作失败:无法更改关系,因为一个或多个外键属性不可为null。更改关系时,相关外键属性设置为null值。如果外键不支持null值,则必须定义新关系,并且必须分配外键属性已删除另一个非空值,或者必须删除不相关的对象。“}

公共部分类子类
{
public int childID{get;set;}
公共int父ID{get;set;}
公共虚拟父CorrectionGroup{get;set;}
公共类父类:EntityTypeConfiguration
{
公父()
{
//主键
this.HasKey(t=>t.childID);
//代码。。。
//关系
this.HasRequired(t=>t.fhther)
.有许多(t=>t.child);
我正在删除一个子项,但出现错误。
谢谢。

你如何删除它?我看不到你的实际代码。只有你的类…它正在工作。谢谢你的回答。
public partial class child
    {
        public int  childID { get; set; }
        public int fatherID { get; set; }


        public virtual father CorrelationCorrecrionGroup { get; set; }

public class father : EntityTypeConfiguration<child>
    {
        public father ()
        {
            // Primary Key
            this.HasKey(t => t.childID);

            //code...



             //Relationships    
            this.HasRequired(t => t.fhther)
                .WithMany(t => t.child);