Entity Framework Core 入門

 今回は「MicrosoftEntityFrameworkCore」を使う際のポイントみたいなものを復習を兼ねてまとめたいと思います。

では、サンプルコードを作って行きます。今回は慣れているFormで作成しました。新しいプロジェクトの作成で、「Windows フォームアプリ」を選択します。

ローカルデータベースの作成

Visual Studioの「表示」→ 「SQL Server オブジェクトエクスプローラー」を選択します。(localdb)\MSSQLLocalDBのデータベースを右クリックして「新しいデータベースの追加」を選択します。名前は何でもいいです。私は「testdb」としました。

NuGetパッケージ追加

次に、プロジェクトのパッケージを右クリックしてNuGetパッケージの管理を選択します。

ここで以下のパッケージをインストールしますが、私の「Windows フォームアプリ」は最新版をインストールするとエラーがでます。.Netのバージョンが7.0なので、そうゆう場合は、7.XX のバージョンをインストールするといいみたいです。

MicrosoftEntityFrameworkCore.SqlServer

MicrosoftEntityFrameworkCore.Tools

これで準備は出来ました。次回はコードファーストでデータベースのテーブルを作っていきます。

Follow me!

コメントする

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny

PAGE TOP