"The main interval of this collaboration should be clearly configured via the relative API or data annotation relation." I get this error in Entity Framework 4.4 while updating / migrating the database, but I am not trying to specify 1: 1 relationship. I want something like this: Where EntityA should have an EntityB original, while EntityB may be the favorite EntityA child, but this does not have to be one of the favorite children to be connected to parents Should, but I do not know how to implement it in the database. I am planning to implement programming. How do I get this error or what is a better way to fulfill these relationships? Entity Framework Code-First Conventions Believe that Since you really want two to-one relationships, so you have to override conferences, with your model it is possible only with the Fluent API: (You can remove You do not specify a mapping Who can ensure that favorite children are always one of the respected children. If you do not want to use the Fluent API, but only the data annotation you can add the archive property to
Public class EntityA {public int id {get; Set; } {EntityBID} Public Entity; Set; } [Foreign key ("Antibid")] Public Virtual EntityB EntityB {get; Set; }} Public category EntityB {public int id {get; Set; } Public taps qualified & lt; Int & gt; Favorite antidepressa {receive; Set; } [Foreign ("PreferredTTAd")] Public Virtual Unit A PriorityAntAa {Received; Set; }}
EntityA.EntityB and
Modelbuilder.Entity & lt; EntityA & gt; () .HasRequired (a => a.EntityB) with .any () HesForeignKey (a => a.EntityBID); Modelbuilder.Entity & lt; EntityB & gt; () .HasOptional (b = & gt; B. PreferredEntityA) .Many (). HesForeignKey (b = & gt; B. PreferredEntityAID);
[ForeignKey] attributes if you use it.)
EntityB and it can relate to
EntityA.EntityB < / Code> using
[InverseProperty] attribute:
public class EntityB {Public Ent ID {Received; Set; } Public taps qualified & lt; Int & gt; Favorite antidepressa {receive; Set; } [Foreign ("PreferredTTAd")] Public Virtual Unit A PriorityAntAa {Received; Set; } [InverseProperty ("EntityB")] // & lt; - Navigation Property Name Public Virtual IcLonac in the ATTTI & lt; EntityA & gt; EntityAs {Receive; Set; }}
No comments:
Post a Comment