I've done this before, I don't know why this is throwing me errors.
These are my classes:
public class ChatModel
{
public int ChatID { get; set; }
public virtual List<ChatModel> Messages { get; set; }
}
public class MessageModel
{
public int MessageID { get; set; }
public string Issuer { get; set; }
public string Message { get; set; }
public ChatModel Chat { get; set; }
}
And this is what I'm doing through Fluent API:
modelBuilder.Entity<ChatModel>()
.HasMany<MessageModel>(c => c.Messages)
.WithRequired(m => m.Chat);
The line that's giving me errors is this one:
.HasMany<MessageModel>(c => c.Messages)
It says:
Error CS0266 Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.ICollection'. An explicit conversion exists (are you missing a cast?)
But honestly, I have absolutely no idea, I've done exactly the same thing with other classes while creating other relationships. But this one is giving me a headache.
Can anybody tell me what I'm doing wrong? Thanks in advance. :)