Reputation: 23648
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..
Upvotes: 1
Views: 2463
Reputation: 8415
The 'hibernate' portion of the key was removed in NHibernate version 2.0. This version is correct for NHibernate 2.0 onwards:
<add key="connection.connection_string" value="xxx" />
Edit: I see that the quickstart doesn't come with the binaries for Castle and NHibernate. You must have downloaded the binaries from somewhere; it would be helpful if you could provide the version number of your NHibernate.dll file.
Confusingly, at least SOME of the quickstart has been updated to be current with NHibernate (NH) 2.0, but the latest 'proper' Castle release is still the 1.0 RC3 (almost a year old now), which does not include NH 2.0.
You can go two ways. You can continue using Castle RC3 and in this case you will indeed need to add the 'hibernate' prefix to your configuration entries. Or you can download a build of Castle from the trunk, which should be running against NH 2.0. The problem with the latter approach is that some of the other breaking changes introduced in NH 2.0 might not be fixed in the quick start.
Upvotes: 1
Reputation: 1525
(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:
[ActiveRecord]
attribute.[PrimaryKey]
attribute.PluralizeTableNames
is "true").virtual
(this one kills me all the time).Upvotes: 1
Reputation: 1525
Delete the "hibernate.
" part for all configuration entries. Your first example is the correct one.
Upvotes: 0