Comment faire un nhibernate fluent un à un de la cartographie?

Comment dois-je faire ce que je suis en train de faire une association.

public class Setting
{
    public virtual Guid StudentId { get; set; }
    public virtual DateFilters TaskFilterOption { get; set; }
    public virtual string TimeZoneId { get; set; }
    public virtual string TimeZoneName { get; set; }
    public virtual DateTime EndOfTerm { get; set; }
    public virtual Student Student { get; set; }

}

//classe carte

 public SettingMap()
        {
           ///Id(Reveal.Member<Setting>("StudentId")).GeneratedBy.Foreign("StudentId");
            //Id(x => x.StudentId);
            Map(x => x.TaskFilterOption).Default(DateFilters.All.ToString()).NvarcharWithMaxSize().Not.Nullable();
            Map(x => x.TimeZoneId).NvarcharWithMaxSize().Not.Nullable();
            Map(x => x.TimeZoneName).NvarcharWithMaxSize().Not.Nullable();
            Map(x => x.EndOfTerm).Default("5/21/2011").Not.Nullable();
            HasOne(x => x.Student);
        }

/étudiant/carte

public class StudentMap : ClassMap<Student>
    {
        public StudentMap()
        {
            Id(x => x.StudentId);
            HasOne(x => x.Setting).Cascade.All();

        }
    }

  public class Student
    {
        public virtual Guid StudentId { get; private set; }
        public virtual Setting Setting { get; set; }
    }

Maintenant, chaque fois que j'essaie de créer un objet de paramètres et de les enregistrer dans la base de données, il se bloque.

   Setting setting = new Setting
                                          {
                                              TimeZoneId = viewModel.SelectedTimeZone, 
                                              TimeZoneName = info.DisplayName, 
                                              EndOfTerm =  DateTime.UtcNow.AddDays(-1),
                                              Student = student
                                          };

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Settings_Students". The conflict occurred in database "Database", table "dbo.Students", column 'StudentId'.
The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Settings_Students". The conflict occurred in database "Database", table "dbo.Students", column 'StudentId'.
The statement has been terminated.

Ce qui me manque?

Modifier

public class StudentMap : ClassMap<Student>
{
public StudentMap()
{
Id(x => x.StudentId).GeneratedBy.Guid();
HasOne(x => x.Setting).PropertyRef("Student").Cascade.All();
}
}
public class SettingMap : ClassMap<Setting>
{
public SettingMap()
{
Id(x => x.StudentId).GeneratedBy.Guid();
Map(x => x.TaskFilterOption).Default(DateFilters.All.ToString()).NvarcharWithMaxSize().Not.Nullable();
Map(x => x.TimeZoneId).NvarcharWithMaxSize().Not.Nullable();
Map(x => x.TimeZoneName).NvarcharWithMaxSize().Not.Nullable();
Map(x => x.EndOfTerm).Default("5/21/2011").Not.Nullable();
References(x => x.Student).Unique();
}
}
//try 1
Setting setting = new Setting
{
TimeZoneId = viewModel.SelectedTimeZone, 
TimeZoneName = info.DisplayName, 
EndOfTerm =  DateTime.UtcNow.AddDays(-1),
Student = student
};
studentRepo.SaveSettings(setting);
studentRepo.Commit();
//try 2
Setting setting = new Setting
{
TimeZoneId = viewModel.SelectedTimeZone, 
TimeZoneName = info.DisplayName, 
EndOfTerm =  DateTime.UtcNow.AddDays(-1),
Student = student
};
student.Setting = setting
studentRepo.CreateStudent(student);
studentRepo.Commit();

J'obtiens ces erreurs pour les deux façons

Invalid index 5 for this SqlParameterCollection with Count=5. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Invalid index 5 for this SqlParameterCollection with Count=5.
Source Error:
Line 76:             using (ITransaction transaction = session.BeginTransaction()) Line 77:   { Line 78:                 transaction.Commit(); Line 79:         } Line 80:         }
InformationsquelleAutor chobo2 | 2011-05-22