Base solution for your next web application
Open Closed

Multi DbContext MSSQL & MySQL #1007


User avatar
0
andmattia created

I try to use 2 db connection 1 to MSSQL (abp-zero [roles,users,etc]) one to business data on MySQL.

I use the sample code from <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-samples/tree/master/MultipleDbContextDemo">https://github.com/aspnetboilerplate/as ... ontextDemo</a> and I create the table and it's work when I call a method, based on a AbpModule to need data from MySql i catch an excection System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Invalid object name 'mdm.app_fd_tb_company'. in System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__167_0(Task1 result) in System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() in System.Threading.Tasks.Task.Execute() So the excetion is relate to System.Data.SqlClient and not to MySql. How can tell to ABP that need to use EF for MySql and not to SQL server.

Another operation that I need to do is to set the initializer Database.SetInitializer<mySqlDbContext>(null); If I not set this row code first say me the database are not update

my db context refered to mysql is declared in this way [DbConfigurationType(typeof(MySqlEFConfiguration))] public class mySqlDbContext : AbpDbContext {


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please follow the discussion here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/980">https://github.com/aspnetboilerplate/as ... issues/980</a>