Subclassmap adds an unwanted column in my table schema
Hello,
I have the following mappings:
public class RosterMap : ClassMap<Roster>
{
public RosterMap()
{
Id(tr => tr.Id)
.GeneratedBy.Increment();
References(tr => tr.Team)
.Not.Nullable();
HasMany(r => r.Players)
.Inverse()
.Cascade.AllDeleteOrphan();
}
}
public class TeamRosterMap : SubclassMap<TeamRoster>
{
public TeamRosterMap()
{
Map(r => r.IsDefault)
.Not.Nullable();
Map(r => r.Name)
.Not.Nullable();
}
}
public class MatchRosterMap : SubclassMap<MatchRoster>
{
public MatchRosterMap()
{
References(rm => rm.Match)
.Not.Nullable();
}
}
which generated the following SQL schema:
create table "Roster" (
Id INTEGER not null,
Team_id INTEGER not null,
primary key (Id)
)
create table "MatchRoster" (
Roster_id INTEGER not null,
Match_id INTEGER not null,
primary key (Roster_id)
)
create table "TeamRoster" (
Roster_id INTEGER not null,
IsDefault INTEGER not null,
Name TEXT not null,
Team_id INTEGER not null,
primary key (Roster_id)
)
Why does TeamRoster has the additional field Team_id, whereas MatchRoster doesn't?
This is a problem, because I get an exception when I want to persist an entity in the database:
System.Data.SQLite.SQLiteException: Abort due to constraint violation
TeamRoster.Team_id may not be NULL
Thanks for your help!
Support Staff 2 Posted by James Gregory on 25 Oct, 2010 01:54 PM
Looks like a bug. What version are you running?
3 Posted by Michael on 25 Oct, 2010 02:12 PM
This doesn't solve my problem, but this may help: if I map again the reference to Team in TeamRoster, things work well:
Any ideas?
4 Posted by Michael on 26 Oct, 2010 08:00 AM
Hello,
I'm using version 1.1
5 Posted by Michael on 26 Oct, 2010 08:51 AM
I don't know if this is related, but I have another problem which looks like the previous one.
With the following mappings:
I have this schema:
What's wrong is the HomeRoster_id field of the PlayerInTeam table, which is not mapped, and shouldn't be there.
I hope this help :)