使用Fluent NHibernate连接到Postgres会抛出异常

问题描述 投票:2回答:1

这是我的Hibernate设置:

FluentConfiguration configuration = Fluently.Configure()
            .Database(PostgreSQLConfiguration.Standard.ConnectionString(c => c
                    .Host("localhost")
                    .Port(5432)
                    .Database("PEDAux")
                    .Username("ped_admin")
                    .Password("xxxxx"))
                .ShowSql)
            .Mappings(m => m.FluentMappings
                .AddFromAssembly(Assembly.GetExecutingAssembly())
                .Conventions.Add<TableNameConvention>()
                .Conventions.Add<ColumnNameConvention>()
            )
            .ExposeConfiguration(x =>
            {
                // TODO: Not yet sure what to put in here
            });

        return configuration.BuildSessionFactory();

我收到以下错误:

内部异常1:HibernateException:无法从NHibernate.Driver.NpgsqlDriver,NHibernate,Version = 5.2.0.0,Culture = neutral,PublicKeyToken = aa95f207798dfdb4创建驱动程序。

内部异常2:TargetInvocationException:调用目标抛出了异常。

内部异常3:ArgumentException:无法找到请求的.Net Framework数据提供程序。它可能没有安装。

当我使用SQLServer时,相同的配置集似乎有效。当然对于SQL Server我使用的是SQLServer配置对象。项目正在.NET Version = v4.7.2“上运行。

fluent-nhibernate npgsql
1个回答
0
投票

根据NpgsqlDriver docs

要使用此驱动程序,您必须为NHibernate提供Npgsql.dll程序集才能加载它。

根据错误,您似乎没有installed Npgsql.dll assembly,或者如果您有,它在您的项目中没有被引用。

© www.soinside.com 2019 - 2024. All rights reserved.