Base solution for your next web application
Open Closed

Database per tenant, how to get records #1635


User avatar
0
kythor created

Hi,

I created a separate tenant with a database. Now I want to query records from that separate db into the frontend, while not logged in. Is there a way to add the tenantId to the custom repositories? Or how can this be done?

I want to be able to add the tenantid and it should automatically get the records from the relevant db.


7 Answer(s)
  • User Avatar
    0
    kythor created

    never mind, found it:

    <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Multi-Tenancy">http://www.aspnetboilerplate.com/Pages/ ... ti-Tenancy</a>

  • User Avatar
    0
    kythor created

    hmm, not working atm.

    when debugging this:

    using (_unitOfWorkManager.Current.SetTenantId(2))
                {
                    var liveStreams = _liveStreamRepository
                                .GetAll()
                                .OrderByDescending(a => a.CreationTime)
                                .ToList();
    
                    return new ListResultOutput<LiveStreamListDto>(liveStreams.MapTo<List<LiveStreamListDto>>());
                }
    

    I get this error:

    The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)
    
  • User Avatar
    0
    kythor created

    note: only when debugging. In a live environment, it works like a charm

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It's probably related to MSDTC configuration on the development machine. This stackoverflow answer explains it in detail <a class="postlink" href="http://stackoverflow.com/a/10131344/6681451">http://stackoverflow.com/a/10131344/6681451</a>

  • User Avatar
    0
    kythor created

    I followed these instructions, but still get errors. I'm using the IP Address in my connectionstring, but tools like DTCPing require Netbios name. Could that be an issue?

    Oh, and when I set breakpoints in the code and do an F5 while first receiving the error, the second time it runs the code without problem, but doesnt load the view (still showing the error)....

  • User Avatar
    0
    kythor created

    Now I'm getting: "attempted to access an unloaded appdomain"...

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I couldn't face a similar probem before, but could it be a firewall issue ? Can you try DTCPing tool ? More info here <a class="postlink" href="http://forums.asp.net/t/2084329.aspx?Problems+with+TransactionScope">http://forums.asp.net/t/2084329.aspx?Pr ... ctionScope</a>