gpt4 book ai didi

.net - 在程序集“SMSApp”中找到了多个迁移配置类型。指定要使用的名称

转载 作者:行者123 更新时间:2023-12-03 13:26:26 25 4
gpt4 key购买 nike

我正在使用代码优先方法开发mvc 5应用程序。

我面临一个问题。第一次,当我尝试使用comands时,它起作用并在该数据库中生成表。但是,当我更改更多类并尝试使用前两个查询时,在这种情况下它可以工作,但是当我尝试使用第三个命令时,它向我显示了此消息。

First step==========enable-migrations -ContextTypeName IdentityDb -MigrationsDirectory DAL\IdentityMigrationsenable-migrations -ContextTypeName SMSContext -MigrationsDirectory DAL\SMSMigrationsSecond Step===========add-migration -ConfigurationTypeName SMSApp.DAL.IdentityMigrations.Configuration "InitialCreate"add-migration -ConfigurationTypeName SMSApp.DAL.SMSMigrations.Configuration "InitialCreate"Third Step==========update-database -ConfigurationTypeName SMSApp.DAL.IdentityMigrations.Configuration -verboseupdate-database -ConfigurationTypeName SMSApp.DAL.SMSMigrations.Configuration -verbose

see the first error:

PM> add-migration -ConfigurationTypeName SMSApp.DAL.IdentityMigrations.Configuration "InitialCreate"
Scaffolding migration ' '.
The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration InitialCreate' again.

A previous migration called 'InitialCreate' was already applied to the target database. If you meant to re-scaffold 'InitialCreate', revert it by running 'Update-Database -TargetMigration $InitialDatabase', then delete '201409261933262_InitialCreate1.cs' and run 'Add-Migration InitialCreate' again.


之后,我执行了以下命令,它给出了以下异常。

更新数据库-TargetMigration $ InitialDatabase-详细

PM> Update-Database -TargetMigration $InitialDatabase -verbose
Using StartUp project 'SMSApp'.
Using NuGet project 'SMSApp'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.Data.Entity.Migrations.Infrastructure.MigrationsException: More than one migrations configuration type was found in the assembly 'SMSApp'. Specify the name of the one to use.
at System.Data.Entity.Utilities.TypeFinder.FindType(Type baseType, String typeName, Func`2 filter, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
More than one migrations configuration type was found in the assembly 'SMSApp'. Specify the name of the one to use.


现在我担心该如何解决?

最佳答案

您需要指定在更新数据库时要使用的配置。

Update-Database -ConfigurationTypeName MyRenamedConfiguration

关于.net - 在程序集“SMSApp”中找到了多个迁移配置类型。指定要使用的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26067259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com