内存中的SQLite不起作用。表未找到错误

时间:2016-09-24 12:12:12

标签: c# sqlite nhibernate

我正在使用Nhibernate和nperistence api,以及实体框架。下面是我的persistence.xml

<provider>NPersistence.NHibernate.NHibernatePersistence</provider>
    <class>CSharp.Node </class>
    <class>CSharp.Edge</class>

<properties>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>  
        <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>  
        <property name="connection.connection_string">Data Source=:memory:</property>  
        <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>  
        <property name="connection.release_mode"> on_close </property> 
        <property name="query.substitutions">true=1;false=0</property>  
        <property name="hbm2ddl.auto" value="update"/>
    </properties>

我的节点类:

using System;
using NPersistence;

namespace CSharp
{
    [Entity]
    [Table(Name = "edge")]
    public class Edge
    {
        [Id]
        [GeneratedValue]
        public virtual int edgeId { get; set;}

        public virtual int fromnode{ get; set; }

        public virtual int tonode { get; set;}

        public virtual string edgelabel{ get; set;}

        public Edge(){
        }
    }
}

在我发现的大多数教程中,设置connection_string =:memory:应该可行。但是当我运行我的项目时,在查询数据库时出现以下错误

NPersistence.PersistenceException: could not execute query
no such table: edge

1 个答案:

答案 0 :(得分:0)

您还需要SchemaExport数据库。这将生成模式(即创建表)