더 많은 지식을 얻기 위해 NHibernate가 실행되도록 노력하고 있습니다.NHibernate : No persister error
나는이 내 핵심 프로젝트에서 내 솔루션
- 코어 클래스 라이브러리 프로젝트
- 기반 클래스 라이브러리 프로젝트
- MVC 응용 프로그램 프로젝트
- 테스트 프로젝트
에 다음과 같은 구조 다음 개체를 생성했습니다 :
내 인프라 프로젝트 0using System;
namespace Core.Domain.Model
{
public class Category
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
}
}
나는 다음과 같은 매핑이 : 다음 설정 파일로
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Core.Domain.Model"
assembly="Core">
<class name="Category" table="Categories" dynamic-update="true">
<cache usage="read-write"/>
<id name="Id" column="Id" type="Guid">
<generator class="guid"/>
</id>
<property name="Name" length="100"/>
</class>
</hibernate-mapping>
: 내 테스트 프로젝트에서
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">server=xxxx;database=xxxx;Integrated Security=true;</property>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="cache.use_query_cache">false</property>
<property name="adonet.batch_size">100</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<mapping assembly="Infrastructure" />
</session-factory>
</hibernate-configuration>
을, 나는 다음과 같은 테스트를해야
[TestMethod]
[DeploymentItem("hibernate.cfg.xml")]
public void CanCreateCategory()
{
IRepository<Category> repo = new CategoryRepository();
Category category = new Category();
category.Name = "ASP.NET";
repo.Save(category);
}
테스트를 실행하려고하면 다음 오류가 발생합니다.
테스트 방법 Volunteer.Tests.CategoryTests.CanCreateCategory 예외가 발생했습니다. NHibernate.MappingException : Core.Domain.Model.Category에 대한 처지가 아닙니다.
도움을 주시면 감사하겠습니다. 임베디드 리소스로 설정된 cfg 빌드 액션이 있습니다.
감사합니다.
ISessionFactory factory = new Configuration().Configure()
.AddAssembly(typeof(Category).Assembly) <========***
.BuildSessionFactory();
같은 난 문제를 추측하고
감사합니다. 동일한 구성 파일을 테스트 어셈블리 (포함 된 리소스로 설정 됨)에 복사했습니다. – Mike
구성 파일 만 포함하고 매핑은 포함하지 않아도됩니다. –
그건 그랬어. 내가 그것을 간과했다라고 생각할 수 없다. 당신의 도움을 주셔서 감사합니다! – Mike