0

これは、LINQ to SQL クラスと 2 つの SQL サーバー (運用環境と開発環境) に関連するベスト プラクティスの質問です。

Azure Cloud で発行する MVC 4 プロジェクトがあります。自動的に切り替える 2 つの接続文字列があります。1 つは本番インスタンス用、もう 1 つはローカルホストで実行する場合で、DB の構造を変更してテストします。この部分は、System.Web.HttpContext.Current.Request.IsLocal

LINQ to SQL クラスを使用する DB コンテキストがありますが、今のところ、DBML 接続文字列を自動的に切り替える方法もわかりません。または、2 つの DBML を使用することもできます。1 つは本番 DB 用で、もう 1 つはテスト用です。

たとえば、テーブルにフィールドを追加し、テスト DB に接続する DBML ファイルを更新して、実験します。プロジェクトを公開する必要がある場合は、まず本番サーバーで SQL 構造を変更し、DBML の接続文字列を手動で変更してから公開する必要があります。

それが最も簡単な方法ですか?

4

1 に答える 1

1

No, you should look into using webdeploy coupled with xdt transforms on your web.config.

For even more ease, instead of linq2sql, consider using linq2entities/entity framework with migrations, which allow you to automate the upgrading of the database in code so you don't have to manually update the schema on the deployment server.

With these 3 technologies you should be able to reduce the pain of deployment down to 2 or 3 clicks once you're all set up (which in itself might be quite painful).

于 2013-01-10T16:20:13.143 に答える