PostgreSQL で Entity Framework Core(Npgsql.EntityFrameworkCore.PostgreSQL) を使っていて、 テーブルの主キーの列に character(n) 型を使っていたら、 エンティティの更新に失敗して嵌った。 再現サンプルは下記の通り。 using Microsoft.EntityFrameworkCore; using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Threading.Tasks; namespace NpgsqlEFSample { [Table("books")] public class Book { [Key] [R
![PostgreSQL で character(n) 型の列を主キーにしていたら Entity Framework Core で酷い目にあった - present](https://cdn-ak-scissors.b.st-hatena.com/image/square/c535009eae660895d365182dafa5338f5b77ecc5/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fg%2Fgriefworker%2F20180522%2F20180522162315.png)