EF Code First - Model
I have 2 classes:
public class Alias
{
public int id { set; get; }
public string Name { set; get; }
public ICollection<Tweet> Tweets { set; get; }
}
public class Tweet
{
public int id {set;get;}
public Alias Author { set; get; }
}
It creates a Author_Id (FK) in the Tweet class. Okay makes sense, because it has a relationship between two models. But how come it doesn't create Tweet_Id (FK) in the Alias class? or is it because I am using ICollection? why it creates a FK in Tweet class and not vice versa?
What keyword tells the EF to create a FK in its model
Also I tried the below code and it fails....
public class Alias
{
public int id { set; get; }
public string Name { set; get; }
public Tweet Tweets { set; get; }
}
public class Tweet
{
public int id {set;get;}
public Alias Author { set; get; }
}
I am trying to understand how the model works, how and when it creates a FK? ... please provide me a brief explanation... Thank you in advance!