I have the DependencyRegistrar figured out but I some how need to further configure the Model in the ObjectContext class. how do I configure 2 instead of 1. code below shows 1.... I did not find any plugins available that have 2 db tables.
/// <summary> /// Further configuration the model /// </summary> /// <param name="modelBuilder">Model muilder</param> protectedoverridevoid OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new TaxRateMap()); base.OnModelCreating(modelBuilder); }
I have the DependencyRegistrar figured out but I some how need to further configure the Model in the ObjectContext class. how do I configure 2 instead of 1. code below shows 1.... I did not find any plugins available that have 2 db tables.
/// <summary> /// Further configuration the model /// </summary> /// <param name="modelBuilder">Model muilder</param> protectedoverridevoid OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new TaxRateMap()); base.OnModelCreating(modelBuilder); }
DbContextOptions only accepts one so you will need to create two.
step:5 create one class file and use INopstartup interface
public class NopStartup : INopStartup { /// <summary> /// Add and configure any of the middleware /// </summary> /// <param name="services">Collection of service descriptors</param> /// <param name="configuration">Configuration of the application</param> public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { //add object context services.AddDbContext<PluginObjectContext>(optionsBuilder => { optionsBuilder.UseSqlServerWithLazyLoading(services); });
/// <summary> /// Configure the using of added middleware /// </summary> /// <param name="application">Builder for configuring an application's request pipeline</param> public void Configure(IApplicationBuilder application) { }
/// <summary> /// Gets order of this startup configuration implementation /// </summary> public int Order => 1001; }
and plugin Install method time call objectContext class file install method that time your multiple tables will be created. it is help for you. Thank you Sagar Kayasth
step:5 create one class file and use INopstartup interface
public class NopStartup : INopStartup { /// <summary> /// Add and configure any of the middleware /// </summary> /// <param name="services">Collection of service descriptors</param> /// <param name="configuration">Configuration of the application</param> public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { //add object context services.AddDbContext<PluginObjectContext>(optionsBuilder => { optionsBuilder.UseSqlServerWithLazyLoading(services); });
/// <summary> /// Configure the using of added middleware /// </summary> /// <param name="application">Builder for configuring an application's request pipeline</param> public void Configure(IApplicationBuilder application) { }
/// <summary> /// Gets order of this startup configuration implementation /// </summary> public int Order => 1001; }
and plugin Install method time call objectContext class file install method that time your multiple tables will be created. it is help for you. Thank you Sagar Kayasth
Thank you so much... Clear and Precise! your post helped me identify my problem. I would vote you up 10 Times if I could!!!
step:5 create one class file and use INopstartup interface
public class NopStartup : INopStartup { /// <summary> /// Add and configure any of the middleware /// </summary> /// <param name="services">Collection of service descriptors</param> /// <param name="configuration">Configuration of the application</param> public void ConfigureServices(IServiceCollection services, IConfiguration configuration) { //add object context services.AddDbContext<PluginObjectContext>(optionsBuilder => { optionsBuilder.UseSqlServerWithLazyLoading(services); });
/// <summary> /// Configure the using of added middleware /// </summary> /// <param name="application">Builder for configuring an application's request pipeline</param> public void Configure(IApplicationBuilder application) { }
/// <summary> /// Gets order of this startup configuration implementation /// </summary> public int Order => 1001; }
and plugin Install method time call objectContext class file install method that time your multiple tables will be created. it is help for you. Thank you Sagar Kayasth
Awsome Work Sagar. I have one another requirement in that. I want to make one to many relationships between Table1Record and Table2Record(Table2Record will have multiple Table1Record records). How can I achive this.
Thank you in Advance.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.