最初の移行はlocalDB上の間違ったDBを更新します
-
21-12-2019 - |
質問
私のASP MVCサイトのデータベースを作成して更新するためのコード最初の移行を使用しています。
私はDBContextを持っています。これは解決策の別のプロジェクトにあります。
public class EFDbContext : DbContext
{
public DbSet<Book> Books { get; set; }
public DbSet<Author> Authors { get; set; }
public DbSet<Publisher> Publishers { get; set; }
}
.
イネーブル - 移行と追加移行の場合 [name] 。
と呼ばれる独自のDBを作成するようです[foo-projectname].Domain.Concrete.EFDbContext
.
[foo-projectname] と呼ばれるデータベースへの添付ファイルの代わりに。 サイトのWebConfigに接続文字列はカタログ " [foo-projectname] "。
WebConfigを他のデータベースに変更した場合、そのデータベースに追加したアイテムから結果を返します。ただし、作成したデータベースを使用します。
この自動作成されたものに固執したくない理由は、SQLServerへの移行を確信しておらず、さらに行を上下にしたくないためです。私はまたエラーを出しています
何も変わっていない場合でも'efdbcontext'コンテキストをバックアップするモデルは...
。
解決
xは、派生DbContext
クラスを含むプロジェクト名です。
-
Default project
のPackage Manager Console
がx であることを確認してください。
- ソリューションのアクティブな起動プロジェクトがX のプロジェクトを確認してください。
別の回避策は、移行構文を実行するときに以下のパラメータを入力します。
-ProjectName X -StartUpProjectName X
.
パラメータの一部説明:
-ProjectName <String>
Specifies the project that contains the migration configuration type to be
used. If omitted, the default project selected in package manager console
is used.
-StartUpProjectName <String>
Specifies the configuration file to use for named connection strings. If
omitted, the specified project's configuration file is used.
-ConfigurationTypeName <String>
Specifies the migrations configuration to use. If omitted, migrations will
attempt to locate a single migrations configuration type in the target
project.
-ConnectionStringName <String>
Specifies the name of a connection string to use from the application's
configuration file.
-ConnectionString <String>
Specifies the the connection string to use. If omitted, the context's
default connection will be used.
. 所属していません StackOverflow