Hello, referring to Domain Resource Usage problem and according to the answer mentioned in it, We are trying to upgrade from v4.6.4 to v5.0.5, but we have errors that wasn't exist in the previous version (those errors appeared after do the required changes and run the application). 1. during a regular linq query, an exception fired requires an open transactions, so I opened a transaction (using session.openTranasction()) and it worked but I don't know if this will be appeared again or not. the second error which stopped me from complete the upgrade is "Can not persist: there are pinned entities". when complete a transaction which contains a change in entities. the Stack Trace is:

   at Xtensive.Orm.Session.Persist(PersistReason reason)
   at Xtensive.Orm.Session.CommitTransaction(Transaction transaction)
   at Xtensive.Orm.Transaction.Commit()
   at Xtensive.Orm.TransactionScope.Dispose()
   at Microtech.Andalus.Business.Features.SaveFeatures(XmlDocument document, Guid cdkey) in d:\Work\FrameWork\Microtech.Andalus.Business\Core\Features.cs:line 95
   at Microtech.Andalus.Security.SecurityService.ValidateAndUpdateLoginTime() in d:\Work\FrameWork\Microtech.Andalus.Business\Security\SecurityService.cs:line 2508
   at Microtech.Andalus.Security.AndalusMembershipProvider.ValidateUser(String username, String password) in d:\Work\FrameWork\Microtech.Andalus.Business\Security\AndalusMembershipProvider.cs:line 462
   at Microtech.Infinity5.Web.Security.Login.ASPxBtnValid_Click(Object sender, EventArgs e) in d:\Work\Application\Microtech.Infinity5.Web\Security\Login.aspx.cs:line 311

Please, inform me with the solution or if I have to follow a specific instruction during upgrade.

thanks

asked Jul 21 '15 at 03:02

ahmad%20emad's gravatar image

ahmad emad
26292931

Hello ahmad emad.

What SessionOptions are enabled for session in which you faced with this exception? We've done some changes in Persist process and changed some SessionOptions.

(Jul 21 '15 at 03:35) Alexey Kulakov Alexey%20Kulakov's gravatar image

Hello Alexey,

we use the following Session configuration in web.config (also, the session's domain is used by SessionManager): <session name="Default" options="LegacyProfile,AllowSwitching,ReadRemovedObjects" commandtimeout="3000"/>

(Jul 21 '15 at 04:23) ahmad emad ahmad%20emad's gravatar image

One Answer:

Hello ahamad emad

Try to add SessionOptions.AutoSaveChanges to options of your session.

Update. We've changed SessionOptions.LegacyProfile since 5.0.0 Beta3. It used to include SessionOptions.AutoTransactionOpenMode but we removed this option so you have to open transaction every time.

Since 5.0.0 Beta2 DO 5.0.x has had an option which allows you don't open transaction but just only for querying - SessionOptions.NotTransactionalReads option. Only SessionOption.ClientProfile option allows not to open transaction but in client profile you have to save all changes manually with Session.SaveChanges(). I think it less comfortable than committing of transaction at the its end.

Also SessionManager opens Session and transaction when you use Session.Demand/Session.Current.

answered Jul 21 '15 at 12:22

Alexey%20Kulakov's gravatar image

Alexey Kulakov
51215

edited Jul 23 '15 at 04:23

Hello Alexey, Thanks, it works. but the first error appeared again request to open a transaction during query from a specific entity without active transaction: Query:Session.Current.Query.All<user>().Where(u => u.Name.ToLower() == userName.ToLower()).FirstOrDefault(); Message: Active Transaction is required for this operation. Use Session.OpenTransaction(...) to open it.
I can open transaction to solve it, but it wasn't exist before and it's repeated in many places, so should I open the transaction to solve the problem(and do that when it appear again) or there is another better solution?

(Jul 22 '15 at 03:59) ahmad emad ahmad%20emad's gravatar image

Hello ahmad emad

I've just updated my answer. Please, check this out.

(Jul 23 '15 at 04:25) Alexey Kulakov Alexey%20Kulakov's gravatar image

Hello Alexey, according to your solution I have to use LegacyProfile and open transactions manually during query, or I have to use ClientProfile and perform SaveChanges() manually.

I tried ClientProfile and the problems appeared till now has been solved and I am going to continue with it, but please inform me if there is anything I have to consider after changing Session Profile(specifically regarding ASP.net + ClientProfile).

Thanks

(Jul 27 '15 at 08:12) ahmad emad ahmad%20emad's gravatar image

I strongly recommend you not to use ClientProfile in asp.net applications. It created for client applications like WPF, WinForms, etc. It decreases communications with database.

Before you make final conclusion you should take into account difference between ClientProfile and ServerProfile, for example.

In SeverProfile or LegacyProfile + AutoSavingChanges (only LegacyProfile in v4.6) DO saves changes every time when it does some query to database (system query or user query). As result, when you query some data from database you always have your changes in results.

(Jul 28 '15 at 11:21) Alexey Kulakov Alexey%20Kulakov's gravatar image

When you enable ClientProfile mode you disable all queries to database except user's queries (inline, delayed query without persist and manual Session.SaveChanges()). Because of it DO creates some cache for changes between Persist operations and uses temporary keys for entities (on save changes DO remap all the new entities to real keys). If you need to have changes in results of some query you should save changes before the query.

I thing it is more complicated to look after all places when you need to save changes. For me just write opening of transaction is simpler then manual save changes

(Jul 28 '15 at 11:38) Alexey Kulakov Alexey%20Kulakov's gravatar image

Hello Alexey, Thanks, I will follow your advice and open transactions manually instead of changing session profile.

(Jul 30 '15 at 02:16) ahmad emad ahmad%20emad's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA