Entity Framework doesnt create all columns - code first

48 Views Asked by At

I want to create a Table with 3 columns, one for each property of my Libro entity, but when the table is created it has only two columns, id and Titulo, without my navigation property "Comments"

This is the Entity class

public class Libro
{
    public int id { get; set; }
    [Required]
    public string Titulo { get; set; }
    public List<Comment> Comments { get; set; }
}

This is the migration file

            migrationBuilder.CreateTable(
                name: "Libros",
                columns: table => new
                {
                    id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Titulo = table.Column<string>(type: "nvarchar(max)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Libros", x => x.id);
                });
1

There are 1 best solutions below

0
Muhammet Ali Songur On

There is no such thing as a database list structure, it is the association structure you create, click on the link for more detailed information.