I am trying to create the first code model in which a Person can have many favorite films, but I do not want FK to be in the Movies table.
The only way to achieve this is to get EF to create a link table between the two objects, and for that (afaik) I have a collection property in the Movies object related to Person ...
public class Person { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public virtual IList<Movie> FavouriteMovies { get; set; } } public class Movie { public int Id { get; set; } public string Name { get; set; } public virtual IList<Person> People { get; set; }
I want the movie to look like this ...
public class Movie { public int Id { get; set; } public string Name { get; set; } }
But at the same time, EF will not create a link table, it will simply hit the Person_Id FK column in the Movies table.
I do not want this to happen, because films should not have anything to do with people, and I could connect them with something else.
So how do I get a cake and eat it?
source share