public class Company
{
public int CompanyID { get; set; }
[StringLength(50)]
public string Name { get; set; }
[StringLength(50)]
public string City { get; set; }
[StringLength(50)]
public string Street { get; set; }
[StringLength(10)]
public string Postcode { get; set; }
[StringLength(50)]
public string Country { get; set; }
public List<Management> ManagementSet { get; set; } = new();
}
public class Management
{
public int ID { get; set; }
public string Name { get; set; }
public string Role { get; set; }
public Company Company { get; set; }
public int CompanyId { get; set; }
}
This will create a Foreign Key in Management that points to table Address instead of table Company :-(
ALTER TABLE [dbo].[Management] WITH CHECK ADD CONSTRAINT [FK_Management_Address_CompanyId] FOREIGN KEY([CompanyId])
REFERENCES [dbo].[Address] ([CompanyID])
ON DELETE CASCADE
GO
2 simple entities:
Context Class with Entity Splitting for Company:
This will create a Foreign Key in Management that points to table Address instead of table Company :-(
I tried to add this:
Makes no difference :-(
provider and version information
EF Core version: 7.0.1 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 7.0 Operating system: Windows