-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuring facets of owned entity types are missing in migrations #9144
Comments
The way you are configuring With that issue in mind, first you are adding EntityType modelBuilder.Entity<Order>()
.OwnsOne(
c => c.BillingAddress,
cb => cb.OwnsOne(
c => c.ZipCode,
z => z.Property(c => c.Value).HasField("_value")));
modelBuilder.Entity<Order>()
.OwnsOne(
c => c.ShippingAddress,
cb => cb.OwnsOne(
c => c.ZipCode,
z => z.Property(c => c.Value).HasField("_value"))); Which generates migration as expected public partial class Init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
BillingAddress_ZipCode_Value = table.Column<int>(type: "int", nullable: false),
ShippingAddress_ZipCode_Value = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");
}
} |
Hi,
I'm playing with complex types in EF Core 2.0 Preview 2 trying to avoid use primitive obsession in my models. Below I show you the code:
When I try to create an initial migration, some weird is happen because my address and zipcodes is nor present in the migration:
If I change the ZipCode entity to use a public property instead of a backing field (For me the perfect approach should be a private property without expose it), EF creates the migration but if a set some value to the property _value it's not storing in db:
It's possible to achieve this? What I'm doing wrong?
Regards!
The text was updated successfully, but these errors were encountered: