locked
Introducing foreign key may causes cycles... RRS feed

  • Question

  • Hello, I have a problem writing in title.

    Here is my POCO entities:

    public class User : Entity
        {
            public User()
            {
                Roles = new HashSet<Role>();
                Lots = new HashSet<Lot>();
            }
    
            public int Id { get; set; }
            public string UserName { get; set; }
            public ContactData ContactData { get; set; }
            public string Password { get; set; }
            public string Email { get; set; }
            public ICollection<Role> Roles { get; set; }
            public virtual ICollection<Lot> Lots { get; set; }
        }

    public class Role : Entity
        {
            public Role()
            {
                Users = new HashSet<User>();
            }
    
            public int Id { get; set; }
            public string Name { get; set; }
            public ICollection<User> Users { get; set; } 
        }

    public class Section : Entity
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public virtual ICollection<Lot> Lots { get; set; }
        }

    public class Lot : Entity
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public double StartPrice { get; set; }
            public double CurrentPrice { get; set; }
            public DateTime CreateDate { get; set; }
            public TimeSpan Duration { get; set; }
            public Currency Currency { get; set; }
            public int CurrencyId { get; set; }
            public User Owner { get; set; }
            public int OwnerId { get; set; }
            public virtual Section Section { get; set; }
            public int SectionId { get; set; }
        }

    public class Comment : Entity
        {
            public int Id { get; set; }
            public string Description { get; set; }
            public string Date { get; set; }
            public virtual User User { get; set; }
            public int UserId { get; set; }
            public virtual Lot Lot { get; set; }
            public int LotId { get; set; }
        }

    Introducing FOREIGN KEY constraint 'FK_dbo.Lots_dbo.Users_OwnerId' on table 'Lots' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.

    How can I fix it?

    :(

    Help me, please.

    Sunday, December 1, 2013 5:28 PM

Answers

All replies