I'm getting the following error when trying to establish the database relationship. But I couldn't establish a relationship:
Unable to determine the relationship represented by navigation 'Event.ApplicationUser' of type 'ApplicationUser'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'
- A user can participate in more than one event.
- A user can have multiple events.
- An event can have multiple participants.
- An event can be created by only one user.
public class Event : EntitySoftDeletableIntKey
{
public string Title { get; set; }
public string ShortContent { get; set; }
public string Place { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int EventDetailId { get; set; }
public EventDetail EventDetail { get; set; }
public int CategoryId { get; set; }
public Category Category { get; set; }
public List<Tag> Tags { get; set; } = new List<Tag>();
public List<Comment> Comments { get; set; } = new List<Comment>();
//This event was published by one user.
public ApplicationUser ApplicationUser { get; set; }
public int ApplicationUserId { get; set; }
//Multiple participants attended this event.
public List<ApplicationUser> Attendees { get; set; } = new List<ApplicationUser>();
public List<FavoriteEvent> FavoriteEvents { get; set; }
}
public class ApplicationUser : IdentityUser<int>
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<FavoriteEvent> FavoriteEvents { get; set; } = new List<FavoriteEvent>();
//This user has posted multiple events.
public List<Event> Events { get; set; } = new List<Event>();
//this user has attended more then one events
public List<Event> AttendedEvents { get; set; } = new List<Event>();
}
Thank you for answers...