标签: npgsql

IIS 7无法加载DLL(拒绝访问)

我在Windows 7上遇到了这个奇怪的问题,它无法加载我正在使用的DLL.然而,它似乎只是在一段时间后发生; 它可以在一段随机的时间内正常工作,直到它开始抛出此消息:

Could not load file or assembly 'Mono.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. Access is denied.
Run Code Online (Sandbox Code Playgroud)

如果我删除了dll并重新添加它,它会在另一段时间内正常工作,之后会再次停止工作.这在asp.net网页和Web服务中都会发生,但是在普通的.net桌面程序中,它可以正常工作.

这只发生在Mono.Security上,而不是我正在使用的任何其他dll(我正在使用依赖于Mono.Security的Npgsql).

如果有人能对此提供一些见解,那就太棒了.

asp.net iis mono web-services npgsql

7
推荐指数
1
解决办法
1万
查看次数

当Npgsql连接池达到Max时会发生什么

连接字符串参数的名称和这篇博客文章 - http://fxjr.blogspot.co.uk/2010/04/npgsql-connection-pool-explained.html - 让我相信Npgsql不会超过MaxPoolSize值在连接字符串中设置.但是,文档(http://npgsql.projects.postgresql.org/docs/manual/UserManual.html)说"连接池的最大大小.如果池包含的内容超过此值,则将在返回池时处理池化连接连接数.默认值:20"

这表明池实际上可能比MaxPoolSize大,实际上它只是一个级别,Npgsql在返回后立即开始积极地从池中删除连接.

我一直在寻找尝试找到答案但我能确切地知道当你到达MaxPoolSize时会发生什么.其他人都知道吗?

编辑:我应该添加我们正在使用Npgsql 2.0.6.0,因为只有该版本支持另一个依赖项.

c# npgsql

7
推荐指数
1
解决办法
4701
查看次数

将字段与值进行比较并返回bool

我正在尝试将哈希从服务器应用程序移动到PostgreSQL.换句话说,我需要调用PGSQL的查询,它将查询中的字符串与字段中的字符串进行比较,并将相等比较的结果返回为bool,但我不知道如何在没有清除SQL的过程的情况下执行此操作.

upd:我有表用户的字段密码(目前是文本,将来 - bytea).我想写一些像

select * from values ('WrittenPassword' = users.password) where username = 'someuser' ,
Run Code Online (Sandbox Code Playgroud)

必须返回true或false作为平等比较的结果.

sql postgresql npgsql

7
推荐指数
1
解决办法
9365
查看次数

如何从连接中使用Entity Framework + PostgreSQL?

我已经看到线程讨论使用Entity Framework和PostgreSQL与官方指令.这些指令需要gacutil针对每个安装运行,这对于部署目的而言并不那么方便.

我想要做的是将PostgreSQL连接直接传递给DbContext构造函数.这对我来说已经足够了,因为我将在CodeFirst没有设计师的情况下使用.这就是我做的:

public class Context : DbContext
{
    Context(System.Data.Common.DbConnection connection)
        : base(connection, true)
    {
    }

    public static Context CreateContext()
    {
        NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=********;Database=xxx;");
        conn.Open();

        return new Context(conn);
    }
}
Run Code Online (Sandbox Code Playgroud)

但是使用这种方法,我收到了一条NotSupportedException消息:

无法确定连接类型为"Npgsql.NpgsqlConnection"的提供程序名称.

我该怎么办?

npgsql entity-framework-4 postgresql-9.1

7
推荐指数
1
解决办法
7120
查看次数

如何使用Npgsql和OrmLite定义'geography'类型(使用postgresql,postgis,c#)

如何在我的C#类模型中定义postgis'geography'类型,以便OrmLite可以轻松地将其传递给Postgresql,这样我除了将空间数据保存到'geography'列之外还可以运行空间查询?

orm geography postgis npgsql ormlite-servicestack

7
推荐指数
1
解决办法
779
查看次数

NPGSQL:使用LWGEOMCOLLECTION类型调用的相关操作

我有一个使用Npgsql获取PostGIS数据的查询.它的目的是取一个点(x,y坐标)并计算出那个(如果有的话)几何形状.对于数据库中的绝大多数几何,查询工作正常,但至少有一个我得到以下异常:

错误:XX000:使用LWGEOMCOLLECTION类型调用的相关操作.这是不受支持的.

堆栈顶部的跟踪是:

[NpgsqlException(0x80004005):错误:XX000:使用LWGEOMCOLLECTION类型调用的相关操作.这是不受支持的.]
Npgsql.d__0.MoveNext()+ 3160
Npgsql.ForwardsOnlyDataReader.GetNextResponseObject(布尔清理)+808 Npgsql.ForwardsOnlyDataReader.GetNextRow(布尔clearPending)+308 Npgsql.ForwardsOnlyDataReader.Read()+47

所有几何都应该是有效的,因为我调用ST_MakeValid任何不是,并且当前没有ST_IsValid返回false.几何图形是通过调用创建的,ST_GeomFromKML并且在地图上使用WMS通过GeoServer作为栅格图层渲染,或者作为矢量图层使用,ST_AsGeoJSON因此PostGIS数据似乎没问题.

有什么办法可以修改我的代码或数据来阻止这种情况发生吗?代码失败的部分是读入读取器的部分:

command.CommandText = "SELECT area_code FROM area WHERE ST_INTERSECTS(ST_SetSRID(ST_Point(:x, :y), 4326), shape) AND area_type_code = :typecode";
command.CommandType = CommandType.Text;
var typeCodeParameter = new NpgsqlParameter
{
    DbType = DbType.String,
    ParameterName = "typecode",
    Value = _typeCode
};
var xParameter = new NpgsqlParameter
{
    DbType = DbType.Double,
    ParameterName = "x",
    Value = _x
};
var yParameter = new NpgsqlParameter
{
    DbType = DbType.Double,
    ParameterName = …
Run Code Online (Sandbox Code Playgroud)

c# postgis npgsql

7
推荐指数
1
解决办法
3599
查看次数

生成.ADO.net实体数据模型时,postgresql不会出现在数据源中

我通过直接使用npgsql成功访问了现有的postgresql dbase.我用过这个:

  1. PostgreSQL 9.0.10(32位)
  2. Visual Studio 2015社区(64位)
  3. NpgSql 2.2.5(通过管理Nuget包)

然而,dbase有25多个表和400多列,我的意图是使用实体框架+ .ADO.net实体数据模型来避免必须对所有列进行代码访问.我在这个网站上搜索并尝试了一切,npgsql网站http: //www.npgsql.org/doc/ddex.html ,...但是我没有成功生成.ADO.net实体数据模型,因为postgresql没有出现在数据源中.

我用过这个:

  1. PostgreSQL 9.0.10(32位)
  2. Visual Studio 2015社区(64位)
  3. NpgSql 2.2.5(通过管理Nuget包)
  4. Setup_Npgsql-2.2.5.0-r3-net45.exe(来自GitHub,因为有些网站表示要求在Visual Studio项目中使用与GAC相同的版本;因为Github错过安装文件,我没有使用3.0.0版本) .
  5. Npgsql.entityframework6 2.2.5(通过Manage Nuget Packages)
  6. Entityframework 6.1.3(通过Manage Nuget Packages)

在尝试生成.ADO.net实体数据模型时,我该怎么做才能使postgresql显示为数据源?
或者Visual Studio 2015社区是否不允许为postgresql生成.ADO网络实体数据模型?

编辑 我添加了以下信息,希望得到答复:

使用Microsoft Windows 8.1 6.3.9600 build 9600 64位

提取出"C:\ Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config"

<system.data>
    <DbProviderFactories>
        <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" support="FF" />
    </DbProviderFactories>
</system.data>
Run Code Online (Sandbox Code Playgroud)

提取出"C:\ Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config"

<system.data>
    <DbProviderFactories>
        <add name="Npgsql Data Provider" invariant="Npgsql" description=".Net Data …
Run Code Online (Sandbox Code Playgroud)

c# postgresql npgsql entity-framework-6 visual-studio-2015

7
推荐指数
1
解决办法
5391
查看次数

Postgresql和实体框架

在我的项目中,我试图使用Entity Framework和PostgreSql.但我无法连接到我的数据库.我没有收到任何错误,只是卡住了.我认为我的问题有些不对劲app.config,但我无法找到答案.

App.config中:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="entityFramework" 
                 type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <entityFramework>
        <defaultConnectionFactory type="Npgsql.NpgsqlFactory, Npgsql" />
        <providers>
            <provider invariantName="Npgsql" 
                      type="Npgsql.NpgsqlServices, Npgsql.EntityFramework"  />
        </providers>
    </entityFramework>
    <system.data>
        <DbProviderFactories>
            <add name="Npgsql Data Provider" invariant="Npgsql" 
                 description="Data Provider for PostgreSQL" 
                 type="Npgsql.NpgsqlFactory, Npgsql" />
        </DbProviderFactories>
    </system.data>
    <connectionStrings>
        <add name="Entities" 
             connectionString="server=localhost;user id=postgres;password=4321;database=postgis" 
             providerName="Npgsql" />
    </connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

DbContext:

public class Entities : DbContext
{
    public Entities() : base("Entities")
    {
    }

    //rest of the code
}
Run Code Online (Sandbox Code Playgroud)

mycode.cs

using (var …
Run Code Online (Sandbox Code Playgroud)

c# postgresql entity-framework npgsql

7
推荐指数
1
解决办法
1万
查看次数

是否可以使用 npgsql 在 EF CORE 3.1 中使用 UNACCENT 扩展对 postgresql 进行选择?

我已经在 Npgsql and Entity Framework Query PostgreSQL with Npgsql and Entity Framework using unaccent中读到过有关此内容,但实体框架核心。

\n\n

是否可以使用 EF CORE 3.1 使用非重音扩展对 postgresql 进行选择?

\n\n

如何翻译,例如

\n\n
\n

select * from users where unaccent(name) = unaccent(\'Jo\xc3\xa3o\')

\n
\n\n

使用 EF core 和 npgsql 到 .net core 3.1

\n\n

谢谢

\n

postgresql npgsql ef-core-3.1

6
推荐指数
1
解决办法
455
查看次数

Postegres ef-core 更新数据库产生“42P01:关系“__EFMigrationsHistory”不存在”错误

设置

Asp.NET core网站2.2和EF Core 2.2
具有多个模式的Postgresql数据库,并且其中一个模式已经有__EFMigrationsHistory


当尝试时

Add-Migration x1 -Context YodaContext 有用

但是当第一次尝试以下语句时
Update-Database -Context YodaContext(我在此架构中没有任何表,这是第一个更新数据库),我看到以下错误。

Failed executing DbCommand (85ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
SELECT "MigrationId", "ProductVersion"
FROM "__EFMigrationsHistory"
ORDER BY "MigrationId";
Npgsql.PostgresException (0x80004005): 42P01: relation "__EFMigrationsHistory" does not exist
   at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext() in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:line 1032
--- End of stack trace from previous location where exception was thrown ---
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming) …
Run Code Online (Sandbox Code Playgroud)

postgresql npgsql entity-framework-migrations ef-core-2.2

6
推荐指数
2
解决办法
8929
查看次数