http://blog.csharpwebdeveloper.com/2011/09/23/nopcommerce-plugin-with-data-access/#comment-59
Skyler Severns said "One other thing to note is that we do not have navigation properties (relational properties), and I’ll cover those in more detail later."
I think this is what I am trying to do - make use of the navigation property 'Address'. Does anyone know how this is done? Thanks.
------------------------------
I'm trying to develop my first plugin which is to be a dealer locator, under 2.2. Seeing how the address table that already exists contains the exact fields that are needed for my dealers, I was trying to reuse it. I figured I could do this since it's already in use by a few different sections (customers/affiliates).
The issue I'm having is this. If I include an address object reference in my dealer baseentity class, when I try to install the plugin, it then tries to recreate address related tables, which causes it to fail. If I don't include the address reference in the baseentity, then the foreign key reference I'm trying to set in the mapping file errors out (the same foreignkey the affiliate table uses).
Listed below are the baseentity and mapping classes I'm using. I can list any of the other plugin files if you think it would help, but I don't think they have any issues in them at this point--they are mostly made up from the examples on blog.csharpwebdeveloper.com or existing nop core plugins that access the database.
If any one that can provide any help to point me in the right directly it would be greatly appreciated.
DealerRecord.cs
using Nop.Core;
using Nop.Core.Domain.Common;
namespace Nop.Plugin.Misc.Dealers.Domain
{
/// <summary>
/// Represents a dealer record
/// </summary>
public partial class DealerRecord : BaseEntity
{
public virtual int AddressId { get; set; }
public virtual bool Active { get; set; }
public virtual string DealerWebSite { get; set; }
public virtual Address Address { get; set; }
}
}
DealerRecordMap.cs
using System.Data.Entity.ModelConfiguration;
using Nop.Plugin.Misc.Dealers.Domain;
namespace Nop.Plugin.Misc.Dealers.Data
{
public partial class DealerRecordMap : EntityTypeConfiguration<DealerRecord>
{
public DealerRecordMap()
{
this.ToTable("Dealer");
this.HasKey(d => d.Id);
this.Property(d => d.AddressId);
this.Property(d => d.Active);
this.Property(d => d.DealerWebSite).HasMaxLength(255).IsOptional();
this.HasRequired(d => d.Address)
.WithMany()
.HasForeignKey(x => x.AddressId)
.WillCascadeOnDelete(false);
}
}
}
I hope I posted this is the right section since I'm fairly new around here. :)