简体   繁体   English

Entity Framework Core DB先行,如何在不同的C#核心项目中添加实体关联

[英]Entity Framework Core DB first, How to add an entity association in different C# core projects

I want to add the Entity folder in the Domain project, DBContext in the Persistence project, both are dll projects, but this script doesn't do it.我想在Domain项目中添加Entity文件夹,在Persistence项目中添加DBContext,都是dll项目,但是这个脚本没有做。

How can I do that?我怎样才能做到这一点?

Scaffold-DbContext -Connection Name=connectionString Microsoft.EntityFrameworkCore.SqlServer -ContextDir DBContext -OutputDir path -Namespace Domain -ContextNamespace Persistence -force Scaffold-DbContext -Connection Name=connectionString Microsoft.EntityFrameworkCore.SqlServer -ContextDir DBContext -OutputDir 路径 -Namespace Domain -ContextNamespace Persistence -force

Thanks.谢谢。

I don't think that's possible.我不认为这是可能的。 You can only specify one target project, where both entites and DbContext are scaffolded.您只能指定一个目标项目,其中 entites 和 DbContext 都在其中搭建。 See the documentation for Scaffold-DbContext command .请参阅Scaffold-DbContext 命令的文档。

If I were you I would set the target project, to your Domain project and then moved the DbContext class to your Persistence project.如果我是您,我会将目标项目设置为您的域项目,然后将 DbContext 类移动到您的持久性项目中。 It's the easiest way.这是最简单的方法。

To specify target project, use the -Project parameter .要指定目标项目,请使用-Project 参数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM