Связь из таблицы X относится к несопоставленному классу: System.Guid

У меня есть этот класс:

public class AttachmentLocation
{
    #region properties

    public virtual Guid UserId { get; set; }

    public virtual Guid LocationId { get; set; }

    public virtual long IndexInLocation { get; set; }

    #endregion

    #region contained foreign objects

    public virtual Attachment Attachment { get; set; }

    #endregion


    #region Methods need to override for CompositeId

    public override bool Equals(object obj)
    {
        if (obj == null)
            return false;
        var t = obj as AttachmentLocation;
        if (t == null)
            return false;
        if (UserId == t.UserId && LocationId == t.LocationId && Attachment.Id == t.Attachment.Id)
            return true;
        return false;
    }

    public override int GetHashCode()
    {
        return (UserId + "|" + LocationId + "|" + Attachment.Id).GetHashCode();
    }

    #endregion

}

У меня есть это Fluent Mapping:

public class AttachmentLocaionMap : ClassMap<AttachmentLocation>
{
    public AttachmentLocaionMap()
    {
        Table("Metadata_AttachmentLocation");
        CompositeId()
            .KeyReference(x => x.UserId, "UserId")
            .KeyReference(x => x.Attachment.Id, "AttachmentId")
            .KeyReference(x => x.LocationId, "LocationId");
        Map(x => x.IndexInLocation).Not.Nullable();
        Map(x => x.LocationId).Not.Nullable();

        HasOne(x => x.Attachment);
    }
}

, которое я регистрирую:

SessionFactory = Fluently.Configure(configuration).Mappings(m =>
{
    m.FluentMappings.AddFromAssemblyOf<AttachmentLocaionMap>();           
    m.FluentMappings.AddFromAssemblyOf<FriendDetailsMap>();
}).BuildSessionFactory();

Я получаю эту ошибку времени выполнения:

Ссылка на ассоциацию из таблицы Metadata_AttachmentLocation в несопоставленный класс : System.Guid

Описание: необработанное исключение произошло во время выполнения текущего веб-запроса. Просмотрите трассировку стека для получения дополнительной информации об ошибке и ее происхождении в коде.

Сведения об исключении: NHibernate.MappingException: ассоциация из таблицы Metadata_AttachmentLocation относится к несопоставленному классу: System.Guid

Ошибка источника:

Строка 19: Строка 20: Строка 21: SessionFactory = Fluently.Configure (конфигурация) .Mappings (m => Строка 22: { Строка 23:
m.FluentMappings.AddFromAssemblyOf ();

Исходный файл: C: \ Users \ elad \ Documents \ Visual Studio 2010 \ Projects \ SVN \ UGI \ Ugi \ Infrastructure \ Dal \ Adapters \ NHibernateAdapter \ NHibernateHelper.cs {{1 }} Строка: 21

Трассировка стека:

[MappingException: ассоциация из таблицы Metadata_AttachmentLocation относится к несопоставленному классу: System.Guid ] NHibernate.Cfg.Configuration.LogAndThrow (исключение исключения) в d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Cfg \ Configuration.cs: 342
{{ 1}} NHibernate.Cfg.Configuration.SecondPassCompileForeignKeys (Таблица таблицы, ISet done) в d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Cfg \ Configuration.cs: 1169
NHibernate.Cfg.Configuration.SecondPassCompile () в d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Cfg \ Configuration.cs: 1120
{{ 1}} NHibernate.Cfg.Configuration.BuildSessionFactory () в d: \ CSharp \ NH \ NH \ nhibernate \ src \ NHibernate \ Cfg \ Configuration.cs: 1249
FluentNHibernate. Cfg.Flue ntConfiguration.BuildSessionFactory () в d: \ Builds \ FluentNH-v1.x-nh3 \ src \ FluentNHibernate \ Cfg \ FluentConfiguration.cs: 227

[FluentConfigurationException: при создании SessionFactory использовалась недопустимая или неполная конфигурация . Проверьте коллекцию PotentialReasons и InnerException для получения дополнительных сведений.

  • База данных не была настроена с помощью метода базы данных. ]
    FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory () в d: \ Builds \ FluentNH-v1.x-nh3 \ src \ FluentNHibernate \ Cfg \ FluentConfiguration.cs: 232 {{ 1}} Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateHelper.OpenSession () в C: \ Users \ elad \ Documents \ Visual Studio 2010 \ Projects \ SVN \ UGI \ Ugi \ Infrastructure \ Dal \ Adapters \ NHibernateAdapter \ NHibernateHelper.cs: 21 {{ 1}} Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateHelper.GetSession () в C: \ Users \ elad \ Documents \ Visual Studio 2010 \ Projects \ SVN \ UGI \ Ugi \ Инфраструктура \ Dal \ Adapters \ NHibernateAdapter \ NHibernateHelper.cs: 36 Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateDal 1..ctor () в C: \ Users \ elad \ Documents \ Visual Studio 2010 \ Projects \ SVN \ UGI \ Ugi \ Infrastructure \ Dal \ Adapters \ NHibernateAdapter \ NHibernateDal.cs: 16 Ugi.Infrastructure.Dal.Adapters.NHibernateAdapter.NHibernateDalFactory. GetDal () в C: \ Users \ elad \ Documents \ Visual Studio 2010 \ Projects \ SVN \ UGI \ Ugi \ Infrastructure \ Dal \ Adapters \ NHibernateAdapter \ NHibernateDalFactory.cs: 17 {{ 1}} Ugi.Server.Sources.Logic.SourcesService..ctor () в C: \ Users \ elad \ Documents \ Visual Studio 2010 \ Projects \ SVN \ UGI \ Ugi \ Server \ Источники \ Logic \ SourcesService.cs: 36
    BuildUp_Ugi.Server.Sources.Logic.SourcesService (IBuilderContext) +153 Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUptext ({1} } контекст) в c: \ EntLib \ UnityTemp \ Compile \ Unity \ Unity \ Src \ ObjectBuilder \ Strategies \ BuildPlan \ DynamicMethod \ DynamicMethodBuildPlan.cs: 37 Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy. PreBuildUp (контекст IBuilderContext ) в c: \ EntLib \ UnityTemp \ Compile \ Unity \ Unity \ Src \ ObjectBuilder \ Strategies \ BuildPlan \ BuildPlanStrategy.cs: 43 Microsoft.Practices .ObjectBuilder2.StrategyChain.ExecuteBuildUp (контекст IBuilderContext ) в c: \ EntLib \ UnityTemp \ Compile \ Unity \ Unity \ Src \ ObjectBuilder \ Strategies \ StrategyChain.cs: 110 Microsoft.Practices.Unity .UnityContainer.DoBuildUp (тип t, объект существующий, имя строки, IEnumerable
    1 resolverOverrides) в c: \ EntLib \ UnityTemp \ Compile \ Unity \ Unity \ Src \ UnityContainer.cs :512

[ResolutionFailedException: Ошибка разрешения зависимости, введите = "Ugi.Common.Model.Sources. ISourcesService ", name =" (нет) ". Исключение произошло при вызове конструктора Ugi.Server.Sources.Logic.SourcesService (). Исключение: FluentConfigurationException - при создании SessionFactory использовалась недопустимая или неполная конфигурация . Проверьте коллекцию PotentialReasons и InnerException для получения дополнительных сведений.

  • База данных не была настроена с помощью метода базы данных.

Как это исправить?

TIA

8
задан Elad Benda 26 November 2011 в 01:09
поделиться