C#NPGSQL实体框架中缺少方法
当我尝试运行以下行时出现错误:
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.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我有用的是:(
应该注意的是,此时(至少如果您正在使用 WinForms)您应该删除“App.config”文件中的 Npgsql 版本 6.0.3 依赖项引用。
如果这对您不起作用,可以在以下链接中找到有关该主题的讨论:https://github.com/elsa-workflows/elsa-core/issues/2544
What worked for me is:
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.
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