動くコード図鑑技術記事現場の渡り方キャリア論すべての記事About
C#

Contextを作る

出典: 【C#】Asp.net Core EFでSqlServerに対しマイグレーションをする方法フェーズ1:プロジェクト側 / Contextを作る

Contextを作る (csharp)#79dce8b7ef74
using Microsoft.EntityFrameworkCore;
 
namespace sqlserver_connection_demo.Models
{
    public class DemoContext : DbContext
    {
        public DemoContext(DbContextOptions<DemoContext> opt):base(opt)
        {
    }
 
    // Modelが増えたらこんな感じで増やしていく。
    public DbSet<User> Users { get; set; }
}
▸ この snippet は実行結果未収録
▸ 実行結果は未収録です
  • id: #79dce8b7ef74
  • lines: 13
  • extracted: 2026-06-10

Source収録記事

この snippet は記事の「フェーズ1:プロジェクト側 / Contextを作る」セクションに登場する。コードの前後の文脈・ハマりどころの解説は記事本文で。

同じ記事から

4
図鑑トップ