C#NPGSQL实体框架中缺少方法

发布于 2025-01-17 14:12:33 字数 1930 浏览 0 评论 0原文

当我尝试运行以下行时出现错误:

FlowsQuerieStartDate tmp = context.FlowsQuerieStartDates

.FirstOrDefault(x =\>       x.Client.Equals(connectionToSQLDatabase.ClientName));

    FlowsQuerieStartDate tmp = 
       context.FlowsQuerieStartDates.FirstOrDefault(x => x.Client.Equals(connectionToSQLDatabase.ClientName));

异常文本为:

'找不到方法:'System.Collections.Generic.IEnumerable`1Npgsql.TypeMapping.INpgsqlTypeMapper.get_Mappings()'.'

这是映射类:

    using Microsoft.EntityFrameworkCore;
    using System;
    
    namespace PostgreSQL.FlowQueryStartDate
    {
    
        public class FlowsQuerieStartDateContext : DbContext
        {
            public DbSet<FlowsQuerieStartDate> FlowsQuerieStartDates { get; set; }
    
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseNpgsql("constring");
            }
    
            protected override void OnModelCreating(ModelBuilder modelBuilder)
            {
                modelBuilder.Entity<FlowsQuerieStartDate>(entity =>
                {
                    entity.ToTable("FlowsQuerieStartDate", "public");
    
                    entity.Property(e => e.Client).HasColumnName("Client");
    
                    entity.Property(e => e.StartDate).HasColumnName("StartDate");
    
                    entity.HasNoKey();
                });
            }
        }
    
        public class FlowsQuerieStartDate
        {
            public string Client { get; set; }
            public DateTime StartDate { get; set; }
        }
    }

.NET Framework 4.7.2

Microsoft.EntityFramework 版本 3.1.3

Npgsql 版本 6.0.3

Npsql.EntityFramework.PostgreSQL 版本 3.1.0

有什么建议吗?这让我大吃一惊...

I have an error when I try to run the following line:

FlowsQuerieStartDate tmp = context.FlowsQuerieStartDates

.FirstOrDefault(x =\>       x.Client.Equals(connectionToSQLDatabase.ClientName));

    FlowsQuerieStartDate tmp = 
       context.FlowsQuerieStartDates.FirstOrDefault(x => x.Client.Equals(connectionToSQLDatabase.ClientName));

The Exception text is :

'Method not found: 'System.Collections.Generic.IEnumerable`1<Npgsql.TypeMapping.NpgsqlTypeMapping> Npgsql.TypeMapping.INpgsqlTypeMapper.get_Mappings()'.'

This is the mapping class:

    using Microsoft.EntityFrameworkCore;
    using System;
    
    namespace PostgreSQL.FlowQueryStartDate
    {
    
        public class FlowsQuerieStartDateContext : DbContext
        {
            public DbSet<FlowsQuerieStartDate> FlowsQuerieStartDates { get; set; }
    
            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
            {
                optionsBuilder.UseNpgsql("constring");
            }
    
            protected override void OnModelCreating(ModelBuilder modelBuilder)
            {
                modelBuilder.Entity<FlowsQuerieStartDate>(entity =>
                {
                    entity.ToTable("FlowsQuerieStartDate", "public");
    
                    entity.Property(e => e.Client).HasColumnName("Client");
    
                    entity.Property(e => e.StartDate).HasColumnName("StartDate");
    
                    entity.HasNoKey();
                });
            }
        }
    
        public class FlowsQuerieStartDate
        {
            public string Client { get; set; }
            public DateTime StartDate { get; set; }
        }
    }

.NET framework 4.7.2

Microsoft.EntityFramework version 3.1.3

Npgsql version 6.0.3

Npsql.EntityFramework.PostgreSQL version 3.1.0

Any suggestion? It's blowing my mind...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿挽旧人 2025-01-24 14:12:33

对我有用的是:(

  1. 通过 NuGet 包管理器)将“Npgsql 版本 6.0.3”降低到“Npgsql 版本 4.1.9”,
    应该注意的是,此时(至少如果您正在使用 WinForms)您应该删除“App.config”文件中的 Npgsql 版本 6.0.3 依赖项引用。
  2. 另外,我的“Npsql.EntityFramework.PostgreSQL 版本”设置为 3.1.18”,尽管我相信您当前的版本应该足够了。

如果这对您不起作用,可以在以下链接中找到有关该主题的讨论:https://github.com/elsa-workflows/elsa-core/issues/2544

What worked for me is:

  1. Lower (through the NuGet Package Manager) the "Npgsql version 6.0.3" to "Npgsql version 4.1.9",
    it should be noted that at that point (at least if you're are working with WinForms) you should delete the Npgsql version 6.0.3 dependency reference in the "App.config" file.
  2. Also my "Npsql.EntityFramework.PostgreSQL version" is set to 3.1.18", althought I believe your current one should suffice.

If this does not work for you, a disscussion on that topic can be found on the following link: https://github.com/elsa-workflows/elsa-core/issues/2544

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文