مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

مهدی الهی

عضویت از 1396/07/29

ارتباط یک Property به چند Property در Asp.net Core

  • پنجشنبه 25 مرداد 1397
  • 09:51
تشکر میکنم

سلام 
میخواستم در کلاس زیر هر 3 پراپرتی(Sen_Id,Rec1_Id,Rev2_Id) رو به ApplicationUser.Id متصل کنم که هر 3 هر کدام برای خودشان از Id از جدول ApplicationUser مقدار بگیرند (یرای هر کدام یک کاربر ثبت بشه)ولی ارور زیر رو نشون میده 
اصلا راه رو درست  رفتم ؟؟
Table.cs

[Key]
        public int Relation_Id { get; set; }
        [Key, ForeignKey("ApplicationUser")]

        public ApplicationUser ApplicationUser_Sender { get; set; }
        public int Sen_Id { get; set; }
        [Key, ForeignKey("ApplicationUser")]
        public ApplicationUser ApplicationUser_Rec1 { get; set; }
        public string Rec1_Id { get; set; }
        [Key, ForeignKey("ApplicationUser")]

        public ApplicationUser ApplicationUser_Rec2 { get; set; }
        public string Rec2_Id { get; set; }

ApplicationUser.cs

public class ApplicationUser : IdentityUser
    {
        public virtual ICollection<Relation> Relation { get; set; }
       

    }

ApplicationDbContext

   builder.Entity<Relation>()
            .HasKey(c => new { c.Relation_Id, c.Sen_Id,c.Rec1_Id,c.Rec2_Id});

Error
Unable to determine the relationship represented by navigation property 'ApplicationUser.Relation' of type 'ICollection<Relation>'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

پاسخ های این پرسش

تعداد پاسخ ها : 1 پاسخ
کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • پنجشنبه 25 مرداد 1397
  • 16:06

اصلا منظورتون رو متوجه نشدم 

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)