ef core 2.0 scaffold-dbcontext 自定义命名空间 [英] ef core 2.0 scaffold-dbcontext custom namespace

查看:40
本文介绍了ef core 2.0 scaffold-dbcontext 自定义命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ef core 2.0 CLI 命令 scaffold-dbcontext 从现有数据库(数据库优先)逆向工程 poco 类.我想将 scaffold-dbcontext 生成的类放在我的项目中的Model"文件夹中,但我希望类的命名空间与MyProjectName.Model"不同.例如,我希望 scaffold-dbcontext 生成的文件位于 Model 文件夹中,但我希望生成的文件的命名空间为MyProjectName.Entities".

I am using the ef core 2.0 CLI command scaffold-dbcontext to reverse engineer poco classes from an existing DB (database first). I want to put the generated classes from scaffold-dbcontext in a "Model" folder within my project but I want the namespace of the classes to be something different than "MyProjectName.Model". For example, I want the scaffold-dbcontext generated files to live in the Model folder but I want the namespace of the genereated files to be "MyProjectName.Entities".

有没有办法用 scaffold-dbcontext cli 命令控制生成的命名空间?

Is there a way to control the generated namespace with the scaffold-dbcontext cli command?

(为了给你一些背景知识,我想在生成的 pocos 中定义自定义命名空间,这样我就可以在另一个文件夹中拥有一组单独的部分类,这些部分类不会通过使用 scaffold-dbcontext 重新生成模型而被覆盖).

(To give you a little background, I want to define the custom namespace in the generated pocos so I can have a separate set of partial classes in another folder which won't be overwritten by regenerating the model using scaffold-dbcontext).

推荐答案

目前没有办法指定命名空间,但是 为 ef 2.1 里程碑开放的类似问题.

Currently no way to specify namespace, but similar issue open for ef 2.1 milestone.

所以我希望它会在下一个版本中修复.

So I hope it will be fixed in the next version.

这篇关于ef core 2.0 scaffold-dbcontext 自定义命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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