Q:

Can I avoid the foreign key properties in my entity?

I have the following classes:
   public class Bicycle
    {
        public int BicycleId { get; set; }
        public DateTime YearOfManufacture { get; set; }
        public int BicycleManufactuerId { get; set; }
        public BicycleManufacturer BicycleManufacturer { get; set; }
    }

    public class BicycleManufacturer
    {
        public int BicycleManufacturerId { get; set; }
        public string Description { get; set; }
    }

Each Bicycle must have a BicycleManufacturer (1:1). There could be some BicycleManufacturer that isn't associate with any Bicycle. Most will be associated with multiple Bicycle entities.
I have the following fluent API code to set up the FK relationship:
    modelBuilder.Entity<Bicycle>()
        .HasRequired(a => a.BicycleManufacturer)
        .WithMany()
        .HasForeignKey(u => u.BicycleManufactuerId);

This all seems to work fine. However, I would really like to remove the BicycleManufacturerId property from the Bicycle entity. It's only there to establish the FK relationship. Is there a way I can create the proper FK relationship if I remove this property?

A:

You can remove the property and use the mapping:
modelBuilder.Entity<Bicycle>()
    .HasRequired(a => a.BicycleManufacturer)
    .WithMany()
    .Map(m => m.MapKey("BicycleManufactuerId"));

