Npgsql is the .NET data provider for Postgresql. It allows any program developed for .NET framework to access a Postgresql database server. It is implemented in 100% C# code. Postgresql versions since 10.0 are officially supported, others may work.
One or more errors occurred. (The type initializer for 'Npgsql.TypeMapping.GlobalTypeMapper' threw an exception.)
---> System.TypeInitializationException: The type initializer for 'Npgsql.TypeMapping.GlobalTypeMapper' threw an exception.
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load type 'Npgsql.Replication.PgOutput.Messages.BeginMessage' from assembly 'Npgsql, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.
...
[JsonObject(IsReference = true)]
public class Customer<T>
{
public string Name { get; set; }
public string LastName { get; set; }
public ICollection<T> Orders { get; set; }
}
static void Main(string[] args)
{
Customer<string> customer = new Customer<string>()
{
Name = "Client1",
LastName ="...",
Orders = new List<string>()
{
"...",
"..."
}
};
string data = JsonConvert.SerializeObject(customer);// Get data from database
Customer<string> other = JsonConvert.DeserializeObject<Customer<string>>(data);
}
Hello.
I am using UseSnakeCaseNamingConvention
extenstion method with communication to postgres by EFCore.
After migration to 5.0 there is error:
System.TypeLoadException: Method 'ProcessForeignKeyOwnershipChanged' in type 'EFCore.NamingConventions.Internal.UpperCaseNameRewriter' from assembly 'EFCore.NamingConventions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' does not have an implementation.
To be honest, I am not sure if is that strictly related to npgsql , but is there maybe anyone how has the same problem?
Npgsql.NodaTime
and Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime
and with optionsBuilder.UseNpgsql(o => o.UseNodaTime());
in my DbContext's OnConfiguring.Instant
as a timestamp, but when I try to Update-Database
it errors out with 42804: column "Timestamp" cannot be cast automatically to type timestamp without time zone
. I don't quite understand why, is NodaTime not properly registering converters?NpgsqlConnection.GlobalTypeMapper.UseNodaTime()
to OnConfiguring? It doesn't make any difference when I run Update-Database though.DateTime
(UTC) before changing it to NodaTime's Instant
, that might be affecting my migration. Any pointers?
class Program
{
static void Main(string[] args)
{
using var ctx = new BlogContext();
ctx.Database.EnsureDeleted();
ctx.Database.EnsureCreated();
var results = ctx.Blogs.Where(b => b.Tags.Contains("A Value")).ToList();
}
}
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql("...");
}
public class Blog
{
public int Id { get; set; }
public string[] Tags { get; set; }
}