2015-08-01から1ヶ月間の記事一覧
データモデルを作成 データ接続用DbContextも同時に作成する。 GoodsModels.cs public class Goods { [Key] [Display(Name="商品ID")] public virtual string Id { get; set; } [Required] [Display(Name = "商品CD")] public string Code { get; set; } [Re…
ModelsのIdentityModelsにIdentityRoleを継承したロールクラスを追加する。 IdentityModels.cs public class ApplicationRole : IdentityRole { public ApplicationRole() : base() { } public ApplicationRole(string pRoleName) : base(pRoleName) { } } A…
Nugetパッケージ管理より、「MySql.Data.Entity」をインストールする。 mysqlで検索し、インストールを行う。 MySql.Data.Entity のインストール時に自動で追加されているので、connectionStrings のみ変更します。web.config <connectionStrings> </connectionstrings>
マイグレーションを活性化 Nugetのパッケージマネージャーコンソールより、以下のコマンドを実行する。 enable-migrationsMigrationsフォルダーが生成され、「Configuration.cs」ファイルが生成される。※DbContextが複数存在する場合は対応DbContextを指定し…
app.config, web.config新しくセクションを定義し、設定を行う。 DB接続情報を登録する例として、1つのデフォルト接続情報と複数のコレクション型を設定する。 完成イメージの.configファイル <configuration> <configSections> <section name="dbSource" type="My.DB.Configuration.DbSourceSectionHandler, My.DB"/> </configSections> <dbSource> </dbsource></configuration>