0

I'm new at Telerik & exploring as an option for ORM. I'm trying to do simple thing like writing a record to database using:

Database db = Database.Get("MyConnectionNameIUsedToGenerateClasses");
IObjectScope scope = db.GetObjectScope();
scope.Transaction.Begin();
LookUpType l = new LookUpType();
l.IsActive = true;
l.Name = "test";
scope.Add(l);
scope.Transaction.Commit();

It throws following error: The connection section with id 'MyConnectionNameIUsedToGenerateClasses' cannot be found in the configuration files traversed from '(OpenAccess internally generated. Is there anything I'm missing from the setup? Telerik did add connectionString to my web.config file with it generated classes. Please help. Thanks.

DAK
  • 1,395
  • 4
  • 22
  • 35

2 Answers2

0

OpenAccess ORM should know of all the assemblies used by the application. The assemblies should be listed under the reference section within the configuration file:

  • Open the web.config file in the web application project;
  • Locate the references node;
  • Alter the references node so that it gets the following form:
<references>
     <reference assemblyname="AssemblyName" configrequired="True" />
</references>

The configuration file format is described here.

Damyan Bogoev
  • 688
  • 4
  • 12
  • For some reason dbContext.Connection works but not Database.Get. So there should not be an issue with references. I used the same link to configure my project – DAK Sep 06 '12 at 20:43
  • 1
    You have created a new domain model using and you are trying to consume it using the Classic API approach. You have to use the OpenAccessContext in order to read and / or persist the changes to the database. You cannot mix both approaches. – Damyan Bogoev Sep 06 '12 at 20:57
  • http://www.telerik.com/help/openaccess-orm/feature-ref-api-context-api-handling-transactions.html – Damyan Bogoev Sep 06 '12 at 21:00
0

As I mentioned in the comments above following code works & does my job:

Telerik.OpenAccess.Data.Common.OAConnection dbConnection = dbContext.Connection;
LookUpType l = new LookUpType();
l.IsActive = true;
l.Name = "test123";

LookUpType lkup = new LookUpType();
lkup.IsActive = true;
lkup.Name = "someTest";

dbContext.Add(new LookUpType[] { l, lkup });
dbContext.SaveChanges();
DAK
  • 1,395
  • 4
  • 22
  • 35