.NET Core Web应用程序启动类中的app.UseMigrationsEndPoint做什么 [英] What app.UseMigrationsEndPoint does in .NET Core Web Application Startup class

查看:109
本文介绍了.NET Core Web应用程序启动类中的app.UseMigrationsEndPoint做什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Visual Studio创建了一个新的.NET Core Web应用程序,并在启动类中生成了这段代码:

I created a new .NET Core Web Application from Visual Studio and I got this piece of code generated in startup class:

if (env.IsDevelopment())
{
    // ***
    app.UseMigrationsEndPoint();
    // ***
}

此行 app.UseMigrationsEndPoint()实际上是什么?官方文档完全没有帮助:

What actually does this line app.UseMigrationsEndPoint()? The official docs are not helpful at all:

处理执行迁移操作的请求.中间件将侦听对DefaultPath的请求.

Processes requests to execute migrations operations. The middleware will listen for requests made to DefaultPath.

默认路径是什么?要发布什么呢?它将实际执行什么?它有任何可选参数吗?它受到某种保护吗?

What's the default path? What to POST to it? What will it actually execute? Does it have any optional parameters? Is it protected somehow?

推荐答案

在链接的文档页面中可能已经看到,它来自EF Core.可以在 GitHub .

As you maybe already seen from the linked documentation page, it comes from EF Core. The exact code, that will be run, can be found on GitHub.

它检查使用的数据库是否有任何挂起的迁移,并在需要时应用它们.就是这样.

It checks if the used database has any pending migrations and will apply them if needed. That's it.

这篇关于.NET Core Web应用程序启动类中的app.UseMigrationsEndPoint做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆