Entity Framework – Entity Framework 4.1: the navigation property ‘businessuser’ declared on the ‘Login’ type has configured the multiplicity of conflicts
•
Java
I have two entities
BusinessUser { Id(PK),Name,...}
Login { BusinessUserID(PK,FK),Email,Password,etc...}
The relationship between businessuser and login is one to many / one
I have the following configuration in the businessuser EF configuration class
this.HasOptional(bu => bu.LoginInfo)
.WithOptionalPrincipal(l => l.BusinessUser);
In the login EF configuration class
this.Hasrequired(l => l.BusinessUser)
.WithOptional(bu => bu.LoginInfo);
I got the following exception
I first use my one to one / zero configuration error in EF 4.1 code
Update 1: the following is my class structure
public class BusinessUser {
public virtual int ID { get; set; }
public virtual int BusinessID { get; set; }
public virtual Business Business { get; set; }
public Login LoginInfo { get; set; }
}
public class Login {
public virtual int BusinessUserID { get; set; }
public virtual string Email { get; set; }
public virtual string Password { get; set; }
public BUsinessUser BusinessUserInfo { get; set; }
}
I'm also looking for a two-way
Solution
Your businessuser must configure the relationship to:
this.HasOptional(bu => bu.LoginInfo)
.Withrequired(l => l.BusinessUser);
The two configurations must be the same (actually only one is required) and the first configuration is incorrect because it attempts to define 0 1 – 0.. 1. Relationship
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
