I use Entity Framework Code First.
I have a class Post with an association to User:
public class User
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Post
{
public int Id { get; set; }
public string Text{ get; set; }
public int UserId { get; set; }
public virtual User User { get; set; }
}
The code above correctly generates primary key (Id) for User and foreign key (UserId) for Post due to Code First Conventions.
But what if I don't want to have navigation property (User) in Post class? Removing that
public virtual User User { get; set; }
results in foreign key not auto-generated for Post.
Can this be done with Fluent API?