2017-10-23 12 views
0

データベースの最初のアプローチ接続文字列を使用するAzure関数があります。接続文字列は、機密データを含むlocal.settings.jsonファイルにあります。Azure関数の接続データベースの文字列Entity Frameworkの最初の承認

{ 
    "IsEncrypted": false, 
    "Values": { 
    "AzureWebJobsStorage": "UseDevelopmentStorage=true", 
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true" 
    }, 
    "ConnectionStrings": { 
    "MyConnectionString": "data source=localhost\\sqlexpress;initial catalog=SampleQrCodes;user id=sa;password=****;MultipleActiveResultSets=True;App=EntityFramework" 
    } 
} 

私はproviderNameでを削除しようとした場合、それは私に次の例外与える:コンテキストがデータベースファーストまたはモデルまずどちらかのためにEDMXファイルから生成されたコードとコードファーストモードで使用されている

を開発。ここで

<add name="DataContext" connectionString="metadata=res://*/EFModel.csdl|res://*/EFModel.ssdl|res://*/EFModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost\sqlexpress;initial catalog=SampleQrCodes;user id=sa;password=***;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

:これは、あなたが

は、実際の接続文字列(EFから生成された)たDbConnectionを取るベースDbContextコンストラクタの1つに渡し.....正しく動作しません同様の質問Load Connection String from Config File in Azure Functionsしかし、それはデータベースの最初のアプローチを介してlocal.settings.jsonでこの接続文字列を定義する方法私のために働いていない?

答えて

1

あなたの説明によると、類似のgit hub issueがここにあります。次のように私のテストごとに、あなたはlocal.settings.jsonファイル内の接続文字列を設定できます。

{ 
    "IsEncrypted": false, 
    "Values": { 
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>", 
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=<account-name>;AccountKey=<account-key>" 
    }, 
    "ConnectionStrings": { 
    "DataContext": { 
     "ConnectionString": "metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string='data source=<server-name>.database.windows.net;initial catalog=<database-name>;persist security info=True;user id=<username>;password=<password>;MultipleActiveResultSets=True;App=EntityFramework'", 
     "ProviderName": "System.Data.EntityClient" 
    } 
    } 
} 

あなたの紺碧の関数に展開するために、あなたはあなたのDbContextを変更する必要があります。詳細は、この類似のissueを参照してください。

関連する問題