如何解决Asp.Net Core如何配置向程序集的迁移类型
大家好,我叫Taniguchi,我学习asp.net核心,我设法创建了一个迁移,但是当我使用Update-Database命令时,向我显示以下错误:“
指定'-Verbose'标志以查看应用于目标数据库的SQL语句。 在程序集“ WebApplication1”中找不到迁移配置类型。 (在Visual Studio中,您可以使用Package Manager控制台中的Enable-Migrations命令来添加迁移配置。)
我的数据库:
public class MimicContext : DbContext
{
public MimicContext(DbContextOptions<MimicContext> options) : base(options)
{
}
public DbSet<Palavra> Palavras { get; set; }
}
我的创业公司:
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application,visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<MimicContext>(opt =>
{
opt.UseSqlite("Data Source=Database\\Mimic.db");
});
services.AddMvc(options => options.EnableEndpointRouting = false);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app,IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
如何配置到程序集的迁移?
解决方法
您是否已在项目中启用迁移?如果不是,那么请使用Enable-Migrations。我认为这可能是问题所在。
,在PMC中运行 update 命令之前,请先将其启用。有关更多详细信息,请查看此链接here
,小错误,但经过一天多的痛苦努力后,对我来说是一个很好的学习。我希望这对其他人来说也是很好的学习。
我添加了两个NuGet软件包:EntityFramework和Microsoft.EntityFrameworkCore,这是我的错。
只需为Microsoft添加NuGet包,EntityFrameworkCore即可完成所有必需的工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。