What does principal end of an association means in 1:1 relationship in Entity framework

后端 未结 3 1080
猫巷女王i
猫巷女王i 2020-11-22 09:33
public class Foo
{
    public string FooId{get;set;}
    public Boo Boo{get;set;}
}


public class Boo
{
    public string BooId{get;set;}
    public Foo Foo{get;set         


        
3条回答
  •  伪装坚强ぢ
    2020-11-22 10:21

    You can also use the [Required] data annotation attribute to solve this:

    public class Foo
    {
        public string FooId { get; set; }
    
        public Boo Boo { get; set; }
    }
    
    public class Boo
    {
        public string BooId { get; set; }
    
        [Required]
        public Foo Foo {get; set; }
    }
    

    Foo is required for Boo.

提交回复
热议问题