Skip to content

Migrations: Compile error when using complex types #31665

@bricelam

Description

@bricelam

With the following model...

public class Entity
{
    public int Id { get; set; }
    public required Point Location { get; set; }
}

[ComplexType]
public class Point
{
    public int X { get; set; }
    public int Y { get; set; }
}   

...adding a migration generates the following code in the snapshot.

b.ComplexProperty<Dictionary<string, object>>("Location", "Entity.Location#Point", b1 =>
    {
        .IsRequired()
        b1.Property<int>("X")
            .HasColumnType("int");

        b1.Property<int>("Y")
            .HasColumnType("int");
    });

It should be as follows

  b.ComplexProperty<Dictionary<string, object>>("Location", "Entity.Location#Point", b1 =>
      {
-         .IsRequired()
+         b1.IsRequired();
          b1.Property<int>("X")
              .HasColumnType("int");

          b1.Property<int>("Y")
              .HasColumnType("int");
      });

This bug is present in 8.0 RC 1.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions