Please help find the error.
Error Text: One or more validation errors were detected during model generation. Because all the qualities in the dependent role are non-futile, the main role should have a plurality of 1.
// File.cs public class file {public entry ID (get; set;} public string name {get} set;} public iconging & lt; Sp & gt; sps {get ; Set;}} // Special Class SP {Public Ent ID (Get; Set;} Public Ink File ID {Get; Set;} Public File File {get} Set;}}
< P> mapping code // mapping file class file: EntityTypeConfiguration & lt; file & gt; {public file () {ToTable ("file", "dbo"); HasKey (x = & Gt; x ;); Property (x = & gt; x.Id) .HasColumnName ("ID"); property (x = & gt; x.Name) .HasColumnName ("NAME");}} // Mapping Spa Class SP: Entity type configuration & lt; Sp & gt; {public (SP) {ToTable ("Sp", "dbo"); HasKey (x => x.Id); Property (x = & gt; x.Id) .HasColumnName ("ID"); Property (x = & gt; x.FileId) .HasColumnName ("FILE_ID"); // The place of error isooptional (d = & gt; d.file) .mind (d = & gt ; D.S.A.). Hwjqqqi (D => Dfile ID) .WillCascadeOnDelete (wrong); }}
You have an alternative foreign key that maps to a non-salient property That is contradictory, you have to go one way or the other.
Change HasOptional
to HasRequired
which means every Sp
should have an associated file
.
If it is not so, then you get the fileID
nullable
public class SP {Public Entity}; Set; } Public int? Get File ID { Set; } Public file file {get; Set; }}
SP
will not be recorded with any file
.
Comments
Post a Comment