LoginSignup
5
4

More than 5 years have passed since last update.

Entity Frameworkで主キーがintegerのカラムにinsertする

Last updated at Posted at 2016-08-05

Entity Frameworkを使ってC#でPostgresqlを操作する。
主キーがintegerのカラムにinsertしようとしたがエラーが出てはまったのでメモ。

エラー内容

Npgsql.PostgresException: 23502: 列"id"内のNULL値はNOT NULL制約違反です

ソースコード

//[Key] //これだけだとエラーが出る
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("id")]
public int Id { get; set; }
5
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4