you can work with 2 databases with nop (I am)
you need to create a new ObjectContext (copy the nop one, change the names and add your tables)
create a new EfStartUpTask (copy the nop one under different namespace)
create all data objects and maps
then in your project you create a new dependencyRegister class and add the new DB connection
u need to create the setting.json as well, copy the nop setting.json and change the name
this is how it should look like, the last section are the tables u add
using Autofac;
using Autofac.Core;
using Nop.Core;
using Nop.Core.Configuration;
using Nop.Core.Data;
using Nop.Core.Domain.WindAlert;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Data;
using Nop.Data.WindAlert;
using Nop.Services.Media;
using Nop.Services.WindAlert;
using Nop.Web.Factories;
namespace Nop.Web.WindAlert
{
public class DependencyRegistrar : IDependencyRegistrar
{
// <summary>
/// Register services and interfaces
/// </summary>
/// <param name="builder">Container builder</param>
/// <param name="typeFinder">Type finder</param>
/// <param name="config">Config</param>
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
{
//windalert
builder.RegisterType<SpotService>().As<ISpotService>().InstancePerLifetimeScope();
#region Data
////data layer
var DataSettingsFilePath = "~/App_Data/newName.json";
var windalertFilePath = CommonHelper.MapPath(DataSettingsFilePath);
//data layer
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings(windalertFilePath, true);
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
//register named context
//register named context
builder.Register<IDbContext>(c => new WindAlertObjectContext(dataProviderSettings.DataConnectionString))
.Named<IDbContext>("nop_object_context_windalert")
.InstancePerLifetimeScope();
builder.Register(c => new WindAlertObjectContext(dataProviderSettings.DataConnectionString))
.InstancePerLifetimeScope();
}
else
{
//register named context
builder.Register<IDbContext>(c => new WindAlertObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.Named<IDbContext>("nop_object_context_windalert")
.InstancePerLifetimeScope();
builder.Register(c => new WindAlertObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.InstancePerLifetimeScope();
}
//override required repository with our custom context
builder.RegisterType<EfRepository<WindData>>()
.As<IRepository<WindData>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<WaveData>>()
.As<IRepository<WaveData>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<ForecastData>>()
.As<IRepository<ForecastData>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
.InstancePerLifetimeScope();
builder.RegisterType<EfRepository<MagicData>>()
.As<IRepository<MagicData>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_windalert"))
.InstancePerLifetimeScope();
#endregion
}
public int Order
{
get { return 1; }
}
}
}