No persistent class could be found.

2 posts, 0 answers
  1. Jaime Weise
    Jaime Weise avatar
    25 posts
    Member since:
    Nov 2008

    Posted 09 Jun 2010 Link to this post

    I have a project which is a console application. I have a project which is a data layer for OpenAccess. I create a persistent class in the MyPoject.Data application and then reference the data application from the console application. I am a getting an error that there are no persistent classes (No persistent class could be found...) but there clearly is.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using Telerik.OpenAccess; 
     
    namespace Elevate.Data 
        [Persistent] 
        public class Customer 
        { 
            public String CustomerName { getset; } 
            public Int32 CustomerNumber { getset; } 
        } 
     

    The namespace is the same and this code resides in the MyProject.Data which I referenced. 
    Here is the console application code that is throwing the error.

                IObjectScope scope = ObjectScopeProvider1.ObjectScope(); 
                scope.Transaction.Begin(); 
                Customer _customer = new Customer(); 
                _customer.CustomerName = "Bob"
                _customer.CustomerNumber = 123; 
                scope.Add(_customer); 
                scope.Transaction.Commit(); 

    Please somebody help me understand what the issue is.
    The full error information is: 

    No persistent class could be found.
    To define persistent classes use the [Persistent] attribute at the class level.
    If multiple projects are used additional references must be made in the configuration file.
    To update the required references use 'Update Config References' from the OpenAccess menu.

    The third line, although I don't understand what it means, looks like it could have some relevancy. It appears something needs to be done in the config but it doesn't say what.

    Any help  would be greatly appreciated.

    Jaime 


  2. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 10 Jun 2010 Link to this post

    Hello jaime,

    In such cases, when persistent classes are used from another project, it is required that after you have added the project reference from the console application to the class library, the console application should be "enabled" to use OpenAccess as well. This will create a needed <reference> node in the config file of the console application that will help OpenAccess find the persistent classes from the other assembly. If you have already enabled the console application but the error remains, use the 'Update Config References' option from the OpenAccess menu to update the required references, as stated in the exception.

    One more thing - I recommend you not to use autoimplemented properties. Currently they are not supported and if you use them you will not be able to use the Forward mapping wizard to customize the mapping. So please implement the private field/public property approach to get the full functionality:
    public class Customer
        {
            private String customerName;
            private Int32 customerNumber;
            public String CustomerName { get { return this.customerName } set { this.customerName = value; } }
            public Int32 CustomerNumber { get { return this.customerNumber } set { this.customerNumber = value; } }
        }

    Hope that helps.


    All the best,
    Damyan Bogoev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
Back to Top