0

I'm building my first biggish web app in ASP.NET MVC using Code First migrations. Every other class is being updated in the database whenever I alter it, but not this class. The UserID and Wallet are being saved, but the Dictionary is always null when referenced in code (even directly after I fill it, save db changes, then extract userproperties again), and there is no mention of it in either dbo.UserProperties or dbo.Media.

Is it maybe not possible to do this? Am I missing something?

Thanks in advance.

Class:

public class UserProperties
{
    [Key]
    [Required]
    public int UserID { get; set; }
    public virtual Wallet Wallet { get; set; }
    public virtual IDictionary<string,Media> Images{  get; set; }

}
Josh Dean
  • 1,593
  • 2
  • 11
  • 17

2 Answers2

1

After reading the following it seems it because of the string key. It needs a class that I wrote.

Entity Framework Code First List<string> Property Mapping

Community
  • 1
  • 1
Josh Dean
  • 1,593
  • 2
  • 11
  • 17
1

You should use ICollection instead of a Dictionary

Dictionary is not supported in EF5/6. You must use traditional one-to-many relation.

ApiFox
  • 123
  • 1
  • 5