Hello,
For a client of ours I need to target a few databases to extract and insert information. Now, I've tried creating the following classes in the EntityFrameworkCore project:
- SecondDbContext.cs
- SecondDbContextConfigurer.cs
- SecondDbContextFactory.cs
I've also added the following in the Preinitialize() of the FirstInterfaceEntityFrameworkCoreModule.cs:
//add linkedin robot db context
Configuration.Modules.AbpEfCore().AddDbContext<SecondDbContext>(configuration =>
{
SecondDbContextConfigurer.Configure(configuration.DbContextOptions, configuration.ConnectionString);
});
But for some reason when I try to use an appservice for the second database, it says table not found because it is trying to connect with the first database.
I'm not sure what i'm doing wrong here? :( Thanks in advance!
5 Answer(s)
-
0
Hi,
Can you share your second DbContext definition ?
Thanks.
-
0
<cite>ismcagdas: </cite> Hi,
Can you share your second DbContext definition ?
Thanks.
Hey, thanks for your response and sorry for the slow reply!
My second DB Context looks as following:
public class SecondDbContext : AbpDbContext { public virtual DbSet<tblRelatie> tblRelatie { get; set; } public SecondDbContext(DbContextOptions<SecondDbContext> options) : base(options) { } }
-
0
Hi,
Sorry, I have missed this somehow. You need to provide connectionString for your second db here
Configuration.Modules.AbpEfCore().AddDbContext<SecondDbContext>(configuration => { SecondDbContextConfigurer.Configure(configuration.DbContextOptions, "ConnectionStringOfSecondDbContext here..."); });
Then it should work.
Thanks.
-
0
Hey ismcagdas,
Thanks a lot :). This works great!
Greetings,
-
0
Thanks for your feedback ;)