I tried to setup a new tenant on my hosted application. I used the create tenant UI to setup the new tenant. The DB was created and all the tables were created in the new DB instance. However the process did not complete normally. The ABP app reported the error message below in the logs.
System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool. ---> System.Runtime.InteropServices.COMException: The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)
I spoke with my hosting support team about this error and if this feature can be enabled. They replied with below.
Unfortunately, MSDTC is not a supported feature on our hosting platform. You can probably find very few shared hosting providers supporting this feature. You should consider using SQL server's native transaction support.
Is there any other method for me to create the tenant?
21 Answer(s)
-
0
Hi,
In this case, you can either disable transaction when creating a new tenant or you can create and migrate tenant database manually.
I couldn't be sure which one is better.
-
0
The tenant DB was created I just don't see the tenant entry in the tenant table or index page of tenants. In the new tenant DB, it does seem to have updated all the tables with data. I dont see the permissions or roles created. At this point I don't know how many steps in the tenant creation process are not completed?
public async Task<int> CreateWithAdminUserAsync(string tenancyName, string name, string adminPassword, string adminEmailAddress, string connectionString, bool isActive, int? editionId, bool shouldChangePasswordOnNextLogin, bool sendActivationEmail) { int newTenantId; long newAdminId; using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
When you say remove transaction from create tenant methods. Are you referring to the "UOW" using stmt above? If yes, this is used in quite a few places in ABP solution. Will I have to remove this everywhere?
-
0
Hi,
@hikalkan offered a better solution, I didn't know about this, sorry for that. You can change your transaction strategy and it should work in this case for you as expected.
Please see this doc carefully <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#transaction-management">http://aspnetboilerplate.com/Pages/Docu ... management</a>. You need to update ABP to latest version. Don't miss this part especially "In addition, your DbContext should have constructors as described in DbContext section of this document."
-
0
Thanks, I performed the ABP upgrade and ran into a build error after upgrade. I posted another forum thread about that issue. Please let me know.
-
0
Thanks, I answered that question as well. Let's continue here when you fix it.
-
0
Thanks! I installed TypeSript for VS2015 now.
After that I get clean build, but now I get error on startup.
Method not found: 'Void EntityFramework.DynamicFilters.DynamicFilterExtensions.Filter(System.Data.Entity.DbModelBuilder, System.String, System.Linq.Expressions.Expression`1<System.Func`3<!!0,!!1,Boolean>>, !!1)'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.MissingMethodException: Method not found: 'Void EntityFramework.DynamicFilters.DynamicFilterExtensions.Filter(System.Data.Entity.DbModelBuilder, System.String, System.Linq.Expressions.Expression`1<System.Func`3<!!0,!!1,Boolean>>, !!1)'.
It looks like someone else reported something similar here: [http://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=3992&p=9018&hilit=Upgrade+error#p9018]), his solution did not work for me :(
I tried this suggestion too: [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1451#issuecomment-264413168])
But then I get this error message:
Could not load file or assembly 'EntityFramework.DynamicFilters' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
-
0
Hi,
You should use EntityFramework.DynamicFilters v1.4.11.0. Can you check your solution and see if there is a newer version referenced ?
If you changed bindingRedirect to <bindingRedirect oldVersion="0.0.0.0-1.4.11.0" newVersion="1.4.11.0" />, probably a newer version reference left somewhere.
-
0
Thanks!
That worked. There were references in the app.config and web.config files throughout the solution for the newer version of EF package.
-
0
<cite>ismcagdas: </cite> Hi,
@hikalkan offered a better solution, I didn't know about this, sorry for that. You can change your transaction strategy and it should work in this case for you as expected.
Please see this doc carefully <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#transaction-management">http://aspnetboilerplate.com/Pages/Docu ... management</a>. You need to update ABP to latest version. Don't miss this part especially "In addition, your DbContext should have constructors as described in DbContext section of this document."
I read the document above. I added the code below into the class Ops17CoreModule, PreInitialize method of my core project. What references do I need in order to make this work? Also, is this the right location for this change?
Configuration.ReplaceService<IEfTransactionStrategy, DbContextEfTransactionStrategy>(DependencyLifeStyle.Transient);
-
0
Hi,
You will ned ABP v1.2.0 or higher. I think you already have this. It is better to place this code in your EntityFramework project.
In addition, your DbContext should have constructors as described in DbContext section here <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/EntityFramework-Integration#DocDbContext">http://aspnetboilerplate.com/Pages/Docu ... cDbContext</a>.
Then it should work.
-
0
I added it to the MyProjectDataModule.cs class in the EF project.
My DBContext class in the EF project already has all the constructors as described in your documentation. Is this all i need to remove the MSDTC based transactions? Do I need to make any other code changes?
Thanks!
-
0
Yes, you are right, this must be all. Now it should work like you want. Did you try it ?
-
0
So I tested my code after making this change. I am now getting the error below in my app service "Update" method where I use "UOW".
System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
The error is triggered on this line of code:
await _unitOfWorkManager.Current.SaveChangesAsync();
I found more details on this error in the logs, see below.
There are some validation errors while saving changes in EntityFramework:- Note: The Note field is required.
So I ran the code in debug and just before the SaveChangesAsync is executed. I can see that "Note" is populated. [https://drive.google.com/open?id=0B5HAoiVVXzY7VnVEZnBtejRxWGM])
Why am I getting error?
-
0
One piece of very good news. The transaction MSDTC error that I was getting on the hosted application has been resolved with the code change you suggested! Thanks very much for helping with that! :D
-
0
I'm glad that it is solved :). Can you share the data in cmp variable ? Can you also share your Note entity ?
Thanks.
-
0
Here is debug showing complete "cmp" object. [https://drive.google.com/open?id=0B5HAoiVVXzY7WVdBM2g0X3pTMkE])
Here are the note entity DTOs. [https://drive.google.com/open?id=0B5HAoiVVXzY7dmFwbUZocDJYd0U])
-
0
Hi,
Your code seems fine to me. I couldn't understand the reason of problem. If you still have this problem, please send your project to us and we will take a look at it.
Thanks.
-
0
I have sent you the solution via email. Thanks!
-
0
Hi,
Thank you for sending the solution. Actually, email activation worked for me in my tests with your solution.
Can you try to send a new passord reset email and see if link works ?
Thanks.
-
0
Wow, I tried it again and this time email link worked!
I emailed you about the company update issue, as that still persists.
Thanks!
-
0
Good news :). I will get back to you about other problem as soon as possible.
Thanks.