Here is an example of how to model a one-to-many relation with Entity Framework using code first.

UseCase: One user can write multiple Blogs, but a Blog is written by one user. This results in a one-to-many relationship between user and blog.

What I like to model looks like this:

one-to-many relation between user and blog

one-to-many relation between user and blog

We need to model two entities: User and Blog.

User.cs

public partial class User
{
    public User()
    {
        this.Blogs = new HashSet<Blog>();
    }
    
    public int Id { get; set; }
    public string Name { get; set; }
    
    public virtual ICollection<Blog> Blogs { get; set; }
}

Blog.cs

public partial class Blog
{
    public int Id { get; set; }
    public string Name { get; set; }
    public Nullable<int> User_Id { get; set; }
    
    public virtual User User { get; set; }
}

Here is the entity framework fluent configuration for the relation:

UserMap.cs

public class UserMap : EntityTypeConfiguration<User>
{
    public UserMap()
    {
        // Primary Key
        this.HasKey(t => t.Id);

        // Properties
        // Table & Column Mappings
        this.ToTable("User");
        this.Property(t => t.Id).HasColumnName("Id");
        this.Property(t => t.Name).HasColumnName("Name");
    }
}

BlogMap.cs

public class BlogMap : EntityTypeConfiguration<Blog>
{
    public BlogMap()
    {
        // Primary Key
        this.HasKey(t => t.Id);

        // Properties
        // Table & Column Mappings
        this.ToTable("Blog");
        this.Property(t => t.Id).HasColumnName("Id");
        this.Property(t => t.Name).HasColumnName("Name");
        this.Property(t => t.User_Id).HasColumnName("User_Id");

        // Relationships
        this.HasOptional(t => t.User)
            .WithMany(t => t.Blogs)
            .HasForeignKey(d => d.User_Id);
    }
}

Further Reading: