导航插入报错 返回

SqlSugar 沟通中
3 151

public class Class1

{

    [SugarColumn(IsPrimaryKey = true, ColumnName = "Id")]

    public string Id { get; set; }

    public string Name { get; set; }

    public string ClassId { get; set; }

    [Navigate(NavigateType.OneToOne, nameof(ClassId))]

    public Class2 Class2 { get; set; }

}

 public class Class2 

 {

     [SugarColumn(IsPrimaryKey = true, ColumnName = "Id")]

     public string Id { get; set; }

     public string Name { get; set; }

 }

DbScoped.SugarScope.InsertNav(class1)

    .Include(z1 => z1.Class2)

    .ExecuteCommand();


Id主键是GUID

导航插入后报错。

null value in column "classid" of relation "class1" violates not-null constraint”

再我使用一对多得时候能够正常生成GUID,能够插入成功

热忱回答3