Article relates to
Telerik OpenAccess ORM
Q3 2012 (version 2012.3.1012)
October 30, 2012
Last modified by
NOTE: This knowledge base article solves a problem that occurs only in Telerik OpenAccess ORM Q3 2012, version 2012.3.1012 DESCRIPTION ASP.NET Web API is the newest framework of Microsoft for building HTTP services exposed to a wide range of clients and since Q3 2012, Telerik OpenAccess ORM supports it in the Add OpenAccess Service wizard.
Add OpenAccess Service saves developers a lot of time by automatically generating C#\Visual Basic code and necessary project files for taking advantage of OpenAccess with a wide variety of services. To do that, the wizard uses several templates, deployed on your machine by the installation of OpenAccess ORM:
In Q3 2012 only, the Delete operation of the generated Web API services throws
Message = Object references between two different object scopes are not allowed. The object 'InvalidOperationExceptionKB.Category' is already managed by 'ObjectScopeImpl 0xa' and was tried to be managed again by 'ObjectScopeImpl 0x9 OpenAccessRuntime.EnlistableObjectScope'
In order to solve the problem, you can choose from the following options:
- Replace two of the T4 code generation templates with the files, attached to this article
- Create a custom template for your current project by modifying the deployed template SOLUTION 1
- Download the attached WebApiBaseRepository.zip
- Extract it on your hard drive
- Copy <extract_dir>\<language>\WebApiBaseRepository.tt
- Update all the Web API services that are already created by re-generating them and build the relevant assemblies
From now on all the Web API services you create will no longer experience this issue when you delete an object. SOLUTION 2
- Create a new folder named OpenAccessTemplates in the host project. The Add OpenAccess Service Wizard is looking for code generation templates from the host project first and then from the OpenAccess installation folder
- Copy <install_dir>\dsl20XX\Extensibility\Dsw\Templates\<language>\WebApiBaseRepository.tt to the OpenAccessTemplates folder
- Add the template in your project
- Delete the automatically generated code file.
- Click on the template and press F4 to view its properties
- Set Build Action to None and delete the text from the Custom Tool property
- Open the template for edit
- Find the following code:
IOpenAccessBaseRepository(Of TEntity, TContext).Delete
TEntity attachedEntity = dataContext.AttachCopy(entity);
TEntity = dataContext.AttachCopy(entity)
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.