什么是dotnet EF数据库更新中的项目?
我有一个由4个项目组成的解决方案:
entityProject
:包含POCO类。上下文Project
:包含从dbContext
衍生的数据库上下文,具有entityProject
的引用。migrationProject
:包含public类空{}
,有一个对context>上下文project
的引用。startupproject
:例如ASP.NET Core WebAPI,有引用上下文Project
和migrationProject
。
在startUpproject
中,我调用migrationAssembly(typeof(migrationProject.empty).sembly.getName()。名称)
从默认上下文protroject更改迁移汇编项目/代码>
MigrationProject
。
如果当前的工作目录是解决方案目录,则我通常会执行以下操作并有效。
迁移
dotnet ef迁移添加初始-project migrationProject-startup-project startupproject
其中- 项目
是强制性的。使用
dotnet EF数据库更新 - 启动project startupproject
其中- 省略项目
。
现在,我想知道为什么dotnet EF数据库更新
还具有- 项目
switch,它是用什么?是否有一个- 项目
是强制性的示例?
总是欢迎任何评论!
I have a solution consisting of 4 projects:
EntityProject
: contains POCO classes.ContextProject
: contains database context derived fromDbContext
, has a reference toEntityProject
.MigrationProject
: containspublic class Empty{}
, has a reference toContextProject
.StartupProject
: for example Asp.Net Core Webapi, has references toContextProject
andMigrationProject
.
In StartupProject
, I invoke MigrationAssembly(typeof(MigrationProject.Empty).Assembly.GetName().Name)
to change the migration assembly project from the default ContextProject
to MigrationProject
.
If the current working directory is the solution directory, I usually do the following and it works.
migration with
dotnet ef migrations add Initial --project MigrationProject --startup-project StartupProject
where--project
is mandatory.updating database with
dotnet ef database update --startup-project StartupProject
where--project
is omitted.
Now I am wondering why dotnet ef database update
also has --project
switch, what is it for? Is there an example in which --project
is mandatory?
Any comments are always welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它只是更新数据库代码路径未使用的一般参数,
请参见源: https://github.com/dotnet/efcore/blob/main/src/src/efcore.design/design/internal/migrationsoperations.cs#l197
It is just a general parameter not used by the Update database code path
See source here: https://github.com/dotnet/efcore/blob/main/src/EFCore.Design/Design/Internal/MigrationsOperations.cs#L197