Plugins and what can and can't be done?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 лет назад
I'm curious as to the extent of what can be done with a plugin vs. adding code to core etc.

Is it possible to extend the EF data model using a plugin? For instance, add tables and their relationships to Nop tables from within the plugin code? I have only just started looking into the extensibility and use of a plugin. We have been using 1.9 but under large database modification to handle assorted added components. Before I port over the code and the changes I would like to verify the correct way to do it as to limit interference with future releases.


If someone could give a list of things that could be done by plugin and what needs to be done by extending core that would be very helpful.
12 лет назад
cybernexus wrote:
Is it possible to extend the EF data model using a plugin? For instance, add tables and their relationships to Nop tables from within the plugin code?

Yes. Have a look at 'Nop.Plugin.Tax.CountryStateZip' payment module to see how it was done.
12 лет назад
Awesome!

Thanks Andrei, I was looking through the plugins for a possible example (must have missed that one).

You guys did an amazing job with this release and I am looking forward to working with it.
12 лет назад
Alright so I reviewed that sample and found it quite useful but i have one additional question...

Is there a way to extend the EF class of say Customer and add navigation properties? I am looking to add tables that contain data that belongs to a customer and the only way I can see that done would be by adding a navigation property to Customer itself? I'm new to the EF Fluent API world so perhaps I'm just thinking about things all wrong.

Example:

New Table


    public partial class EmailNewsletter : BaseEntity
    {
        public virtual int CustomerId { get; set; }
        public virtual string Name { get; set; }
        public virtual int Type { get; set; }
        public virtual int TemplateID { get; set; }
        public virtual int? FrequencyType { get; set; }
        public virtual DateTime StartDate { get; set; }
        public virtual bool? isActive { get; set; }

        public virtual Customer Customer { get; set; }
    }


Mapping


    public partial class EmailNewsletterMap : EntityTypeConfiguration<EmailNewsletter>
    {
        public EmailNewsletterMap()
        {
            this.ToTable("EmailNewsletter");
            this.HasKey(c => c.Id);
            this.Property(u => u.Name).IsRequired();
            this.Property(u => u.Type).IsRequired();
            this.Property(u => u.FrequencyType).IsOptional();
            this.Property(u => u.StartDate).IsRequired();
            this.Property(u => u.isActive).IsOptional();

            // navigation property does not exist in customer model
            this.HasRequired(c => c.Customer).WithMany().HasForeignKey(c => c.CustomerId);
        }
    }
12 лет назад
cybernexus wrote:
Is there a way to extend the EF class of say Customer and add navigation properties? I am looking to add tables that contain data that belongs to a customer and the only way I can see that done would be by adding a navigation property to Customer itself? I'm new to the EF Fluent API world so perhaps I'm just thinking about things all wrong.

I think it's not possible due to Entity Framework implementation (one entity can't belong to two contexts)

BTW, you can use CustomerAttribute table to extend 'Customer' entity.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.