繁体   English   中英

Npgsql 实体框架中的 C# 缺少方法

[英]C# missing method in Npgsql Entity Framework

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

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`1<Npgsql.TypeMapping.NpgsqlTypeMapping> Npgsql.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 框架 4.7.2

Microsoft.EntityFramework 版本 3.1.3

Npgsql 版本 6.0.3

Npsql.EntityFramework.PostgreSQL 版本 3.1.0

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

对我有用的是:

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM