Search code examples
orm.net-3.5documentationcastle-activerecord

Castle-ActiveRecord Tutorial with .NET 3.5 broken?


Has anyone tried the ActiveRecord Intro Sample with C# 3.5? I somehow have the feeling that the sample is completely wrong or just out of date. The XML configuration is just plain wrong:

<add key="connection.connection_string" value="xxx" />

should be :

<add key="hibernate.connection.connection_string" value="xxx" />

(if I understand the nhibernate config syntax right..)

I am wondering what I'm doing wrong. I get a "Could not perform ExecuteQuery for User" Exception when calling Count() on the User Model.

No idea what this can be. The tutorial source differs strongly from the source on the page (most notably in the XML configuration), and it's a VS2003 sample with different syntax on most things (no generics etc).

Any suggestions? ActiveRecord looks awesome..


Solution

  • (This was too long for a comment post)

    [@Tigraine] From your comments on my previous answer it looks like the error lies not with the configuration, but with one of your entities. Removing the "hibernate" corrected the configuration so that it geve you the real error, which appears to be that the entity "Post" is not properly attributed for ActiveRecord to create its mapping.

    If you further down in the error that it gives, it likely has some details as to what about "Post" failed.

    Some common things include:

    • THe class does not have the [ActiveRecord] attribute.
    • There is no property with the [PrimaryKey] attribute.
    • There is no matching table called "Post" (or "Posts" if PluralizeTableNames is "true").
    • There is no matching column(s) for attributed properties.
    • Your attributed properties and public methods are not virtual (this one kills me all the time).