Add one-to-one relationship between RecAction and OutRes
Introduced a new `OutRes` navigation property in the `RecAction` class to establish a one-to-one relationship with the `OutRes` entity. Updated `RecDbContext` to configure this relationship using the Fluent API. The `OutRes` entity references its associated `RecAction` via the `Action` navigation property, with `ActionId` as the foreign key.
This commit is contained in:
parent
74f4d06031
commit
b00902e461
@ -69,4 +69,6 @@ public class RecAction
|
|||||||
|
|
||||||
[Column("CHANGED_WHEN")]
|
[Column("CHANGED_WHEN")]
|
||||||
public DateTime? ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
|
||||||
|
public OutRes? OutRes { get; set; }
|
||||||
}
|
}
|
||||||
@ -35,5 +35,10 @@ public class RecDbContext(DbContextOptions<RecDbContext> options) : DbContext(op
|
|||||||
modelBuilder.Entity<HeaderQueryResult>().HasNoKey();
|
modelBuilder.Entity<HeaderQueryResult>().HasNoKey();
|
||||||
|
|
||||||
modelBuilder.Entity<BodyQueryResult>().HasNoKey();
|
modelBuilder.Entity<BodyQueryResult>().HasNoKey();
|
||||||
|
|
||||||
|
modelBuilder.Entity<RecAction>()
|
||||||
|
.HasOne(act => act.OutRes)
|
||||||
|
.WithOne(res => res.Action)
|
||||||
|
.HasForeignKey<OutRes>(res => res.ActionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user