Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Castle Active Record Rookie Misteak - HasMany mapping woes

In trying to map a simple ISet<string> within an Active Record class my app kept bombing while trying to perform the SchemaExport during app initialization. Here's the error I get resulting from some call in ActiveRecordStarter.cs:

The given key was not present in the dictionary.

I knew this was related to the following property in my User class:

[HasMany(typeof(System.String),"UserId","UserRoles",
    Access = PropertyAccess.FieldCamelcase,
    RelationType = RelationType.Set
    )]
public virtual ISet<System.String> Roles
{
    get { return roles; }
}

 

Not until I went in to manually create my table did it dawn on me what I was missing:

    Element = "Role"

DOH! I should have gone and looked at other mappings I have created by hand before chasing this down...so now it looks like:

[HasMany(typeof(System.String),"UserId","UserRoles",
    Access = PropertyAccess.FieldCamelcase,
    RelationType = RelationType.Set,
    Element = "Role"
    )]
public virtual ISet<System.String> Roles
{
    get { return roles; }
}

 

All is well again.


Posted 10-02-2007 2:11 PM by Michael Nichols

[Advertisement]

Comments

Christopher Steen wrote Link Listing - October 4, 2007
on 10-05-2007 4:09 AM

Link Listing - October 4, 2007

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)