Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "mhdbaz"

I found the solution its because of EntityFramework.DynamicFilters 2.2.0

I down grade EntityFramework.DynamicFilters to 1.4.11 and its working.

I found the solution its because of EntityFramework.DynamicFilters 2.2.0

I down grade EntityFramework.DynamicFilters to 1.4.11 and its working.

<cite>hikalkan: </cite> If you are injecting application service via class (like YourAppService) instead of interface (like IYourAppService) then you should make your app service method as virtual. Thus, you can remove UnitOfWork attr from the controller.

Ok thanks

<cite>hikalkan: </cite> Hi,

Since this topic is asked by also other people, I decided to prepare a simple running application. Download it from here: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-samples/tree/master/Others">https://github.com/aspnetboilerplate/as ... ter/Others</a>

I created 2 different DbContext and 2 different migrations in same project. See migration command reference: <a class="postlink" href="http://coding.abel.nu/2012/03/ef-migrations-command-reference/">http://coding.abel.nu/2012/03/ef-migrat ... reference/</a>

I added a new connection string named 'Second':

<add name="Default" connectionString="Server=localhost; Database=MultipleDbContextDemo; Trusted_Connection=True;" providerName="System.Data.SqlClient" />
   <add name="Second" connectionString="Server=localhost; Database=MultipleDbContextDemoSecondDb; Trusted_Connection=True;" providerName="System.Data.SqlClient" />

Then Added second db context:

public class MySecondDbContext : AbpDbContext
   {
       public virtual IDbSet<Course> Courses { get; set; }

       public MySecondDbContext()
           : base("Second")
       {
           
       }
   }

Then enabled migrations:

Enable-Migrations -MigrationsDirectory "MigrationsSecond" -ContextTypeName "MySecondDbContext"

When using add-migration and update database, we use configuration type name, like:

Update-Database -ConfigurationTypeName "MultipleDbContextDemo.MigrationsSecond.Configuration"

An application services both dbcontext (over 2 repositories):

public class TestAppService : MultipleDbContextDemoAppServiceBase, ITestAppService
   {
       private readonly IRepository<Person> _persons;
       private readonly IRepository<Course> _courseRepository;

       public TestAppService(IRepository<Person> persons, IRepository<Course> courseRepository)
       {
           _persons = persons;
           _courseRepository = courseRepository;
       }

       public List<string> GetFromFirstDb()
       {
           var peopleNames = _persons.GetAllList().Select(p => p.PersonName).ToList();
           return peopleNames;
       }

       public List<string> GetFromSecondDb()
       {
           var courseNames =  _courseRepository.GetAllList().Select(p => p.CourseName).ToList();
           return courseNames;
       }

       public List<string> GetFromBothDbs()
       {
           List<string> names = new List<string>();

           var peopleNames = _persons.GetAllList().Select(p => p.PersonName).ToList();
           names.AddRange(peopleNames);

           var courseNames = _courseRepository.GetAllList().Select(p => p.CourseName).ToList();
           names.AddRange(courseNames);

           return names;
       }
   }

Note that: GetFromBothDbs() may not work. You should start Distributed Transaction Coordinator windows service..

For details, see source codes. After downloading solution, first create 2 databases using following commands:

Update-Database -ConfigurationTypeName "MultipleDbContextDemo.Migrations.Configuration"

Update-Database -ConfigurationTypeName "MultipleDbContextDemo.MigrationsSecond.Configuration"

I hope this help you.

Hello Halil I was reading about unit of work and How aspnetboilerplate automatically start a transaction on calling any Application Service method here <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work">http://aspnetboilerplate.com/Pages/Docu ... it-Of-Work</a> Do you mean that Starting the MSDTC on the server will fix the issues regarding starting Two transaction ? Dose aspnetboilerplate unit of work deal with this scenarios where multi tenant application should use different database for each tenant ? Please help because I am new to aspnetboilerplate and I also should use Single Application/Multi Database approach.

My scenario is Single Deployment - Multiple Database in the below link I just want to make sure that aspnetboilerplate work with Single Deployment - Multiple Database or How I should implement my Application Service classes in order to get aspnetboilerplate works with Single Deployment - Multiple Database <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy">http://aspnetboilerplate.com/Pages/Docu ... ti-Tenancy</a>

Thank you

Showing 1 to 4 of 4 entries