© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
6 replies
Marcoelho97

✅ Multiple one to many relationships

I've just recently started using ASP.NET and I ran into a bit of a wall
Basically:
    public class Reserva
    {
        public int Id { get; set; }

        public string ClienteId { get; set; }
        public ApplicationUser Cliente { get; set; }

        public string FuncionarioId { get; set; }
        public ApplicationUser Funcionario { get; set; }
    }

    public class ApplicationUser : IdentityUser
    {
        public Empresa? Empresa { get; set; }
        public ICollection<Reserva> Reservas { get; set; }
        public ICollection<Reserva> EntregasRecolhas { get; set; }

    }
    public class Reserva
    {
        public int Id { get; set; }

        public string ClienteId { get; set; }
        public ApplicationUser Cliente { get; set; }

        public string FuncionarioId { get; set; }
        public ApplicationUser Funcionario { get; set; }
    }

    public class ApplicationUser : IdentityUser
    {
        public Empresa? Empresa { get; set; }
        public ICollection<Reserva> Reservas { get; set; }
        public ICollection<Reserva> EntregasRecolhas { get; set; }

    }


How do I make a migration of this? I'm getting "Unable to determine the relationship represented by navigation 'ApplicationUser.EntregasRecolhas' of type 'ICollection<Reserva>'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'."
And I don't know how to proceed without having to manually do it ( which I don't know how to do it either )
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

One-to-many relationships - EF
C#CC# / help
2y ago
Multiple 1 to Many Relationships in Entity Framework
C#CC# / help
2y ago
❔ Querying Many to Many EF Relationships
C#CC# / help
3y ago