1
エンティティフレームワークセクションを含むweb.configファイル設定があります。Asp.net Web.config Entity Frameworkセクションの変換挿入セクション
Web.configファイル
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
しかし、私はデバッグ中に、データベースの初期化子を使用します。だから私はWeb.Debug.config
ファイルのエンティティフレームワークセクションを使用したいと思います。 xdt:Transform="Insert"
と
Web.Debug.configファイル:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<entityFramework>
<contexts xdt:Transform="Insert">
<context type="MyProject.DashboardContext, MyProject.Data">
<databaseInitializer type="MyProject.ContexttInitializer, MyProject.Data"></databaseInitializer>
</context>
</contexts>
</entityFramework>
は、しかし、これはContexttInitializer
クラスを実行しません。 Web.configファイルにこのセクションを追加すると、このセクションが実行されます。
あなたは右のVisual StudioのソリューションエクスプローラでWeb.Debug.configをクリックして、変換をテストし、コンテキスト要素があなたの変換ウェブに挿入されていることを確認することができます.config –
デバッグトランスフォームを使用する場合は、サイトをデバッグサーバーにデプロイするか、単にF5キーを押してアプリケーションを実行しますか? – DavidG
はい、F5でデバイギングします。設定は正しいですか? – barteloma