How do I make these models work with Entity Framework?

A long time ago I started working on a simple project to learn a bit more about ASP.NET. A bit later I decided to use a database for storage instead of serialization, so I updated my existing models somewhat to try and make them work with Entity Framework code-first. Unfortunately, it seems that these classes are too complex to be converted to database tables.

Here are the models.

Take this part for example:

// Profile.cs ... public virtual List<Profile> Friends { get; set; } public virtual List<Community> Subscriptions { get; set; } public virtual List<Community> Owned { get; set; } // Community.cs ... public virtual Category Category { get; set; } public virtual Profile Owner { get; set; } public virtual List<Profile> Subscribers { get; set; } 

I don’t think this is going to work as it’s supposed to, with multiple collections of entities of the same type referenced by another entity it’s getting messy without a hierarchy-like structure of data.

How can I make these models more EF friendly?

submitted by /u/MrReynevan2
[link] [comments]

Leave a Reply