I am developing a custom plugin for NOP.
I need a custom table that the plugin can use to store some data....
I have been following this step by step tutorial:
http://docs.nopcommerce.com/display/nc/Plugin+with+data+access
But, when I try and build my solution I get 4 errors which I don't understand.
I my ObjectContext it is reporting:
'Nop.Plugin.Misc.ChiliPublisher.Data.ChiliOrdersObjectContext' does not implement interface member 'Nop.Data.IDbContext.ProxyCreationEnabled'
'Nop.Plugin.Misc.ChiliPublisher.Data.ChiliOrdersObjectContext' does not implement interface member 'Nop.Data.IDbContext.Detach(object)'
'Nop.Plugin.Misc.ChiliPublisher.Data.ChiliOrdersObjectContext' does not implement interface member 'Nop.Data.IDbContext.AutoDetectChangesEnabled'
Here is my code:
using Nop.Core;
using Nop.Data;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Nop.Plugin.Misc.ChiliPublisher.Data {
public class ChiliObjectContext : DbContext, IDbContext {
public ChiliObjectContext(string nameOrConnectionString) : base(nameOrConnectionString) { }
#region Implementation of IDbContext
#endregion
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
modelBuilder.Configurations.Add(new ChiliOrdersMap());
base.OnModelCreating(modelBuilder);
}
public string CreateDatabaseInstallationScript() {
return ((IObjectContextAdapter)this).ObjectContext.CreateDatabaseScript();
}
public void Install() {
//It's required to set initializer to null (for SQL Server Compact).
//otherwise, you'll get something like "The model backing the 'your context name' context has changed since the database was created. Consider using Code First Migrations to update the database"
Database.SetInitializer<ChiliObjectContext>(null);
Database.ExecuteSqlCommand(CreateDatabaseInstallationScript());
SaveChanges();
}
public void Uninstall() {
var dbScript = "DROP TABLE ChiliOrders";
Database.ExecuteSqlCommand(dbScript);
SaveChanges();
}
public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity {
return base.Set<TEntity>();
}
public System.Collections.Generic.IList<TEntity> ExecuteStoredProcedureList<TEntity>(string commandText, params object[] parameters) where TEntity : BaseEntity, new() {
throw new System.NotImplementedException();
}
public System.Collections.Generic.IEnumerable<TElement> SqlQuery<TElement>(string sql, params object[] parameters) {
throw new System.NotImplementedException();
}
public int ExecuteSqlCommand(string sql, bool doNotEnsureTransaction = false, int? timeout = null, params object[] parameters) {
throw new System.NotImplementedException();
}
}
}
And in my DependencyRegistrar it is reporting an error of:
'Nop.Plugin.Misc.ChiliPublisher.DependencyRegistrar' does not implement interface member 'Nop.Core.Infrastructure.DependencyManagement.IDependencyRegistrar.Register(Autofac.ContainerBuilder, Nop.Core.Infrastructure.ITypeFinder, Nop.Core.Configuration.NopConfig)'
and my code is:
using Autofac;
using Autofac.Core;
using Nop.Core.Data;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Data;
using Nop.Plugin.Misc.ChiliPublisher.Data;
using Nop.Plugin.Misc.ChiliPublisher.Domain;
using Nop.Plugin.Misc.ChiliPublisher.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nop.Web.Framework.Mvc;
namespace Nop.Plugin.Misc.ChiliPublisher {
public class DependencyRegistrar : IDependencyRegistrar {
private const string CONTEXT_NAME = "nop_object_context_chili_orders";
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder) {
builder.RegisterType<ViewChiliPublishingService>().As<IViewChiliPublishingService>().InstancePerLifetimeScope();
//data context
this.RegisterPluginDataContext<ChiliObjectContext>(builder, CONTEXT_NAME);
//override required repository with our custom context
builder.RegisterType<EfRepository<ChiliOrders>>()
.As<IRepository<ChiliOrders>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>(CONTEXT_NAME))
.InstancePerLifetimeScope();
}
public int Order {
get { return 1; }
}
}
}
I have been back through the instructions multiple times but cannot see what I have missed.
Can anyone offer any help please?