I have two tables.
CREATE TABLE [dbo].[BusinessUnit](
[BusinessUnitId] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[CurrencyId] [int] NOT NULL);
CREATE TABLE [dbo].[Currency](
[CurrencyId] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](35) NOT NULL,
[Country] [nvarchar](50) NOT NULL,
[Code] [nvarchar](50) NOT NULL);
I have an Entity
public class BusinessUnit
{
public int Id { get; set; }
public string Name { get; set; }
public int CurrencyId { get; set; }
public string CurrencyCode { get; set; }
}
I want to use Entity Splitting to pull in the dbo.Currency.Code field. My mapping isn't working. Here is the mapping.
class BusinessUnitMap : EntityTypeConfiguration<BusinessUnit>
{
public BusinessUnitMap()
{
Property(bu => bu.Id).HasColumnName("BusinessUnitId");
ToTable("BusinessUnit");
Map(map =>
{
map.Property(bu => bu.CurrencyId);
map.Property(bu => bu.CurrencyCode).HasColumnName("Code");
map.ToTable("Currency");
});
}
}
I have tried a few other variations of this. I can't figure out how to get the mapping to work. It keeps producing SQL joining on the BusinessUnitId. I need the join to occur on CurrencyId.