S#arp 架构和 CRUD 脚手架

发布于 2024-09-25 17:04:27 字数 228 浏览 0 评论 0原文

我很确定我在这里有点困惑(我什至对被困惑感到困惑)。

我已经在 SQL Server 2008 中创建了数据库。

我现在第一次尝试 S#arp 架构,并且正在研究使用 CRUD 脚手架。从说明来看,我基本上必须在 ScaffoldingGeneratorCommand.tt 文件中重新创建整个数据库?对我来说有点毫无意义,对吧?

我想在这里倒退吗?我想做的就是从现有数据库转到 CRUD 类。

I'm pretty sure I am a bit confused here (I'm even confused about being confused).

I've already created my database in SQL Server 2008.

I'm now trying out S#arp Architecture for the first time and I'm was looking into using CRUD scaffolding. From the instructions it seems like I basically have to RECREATE the entire database within the ScaffoldingGeneratorCommand.tt file? Kinda pointless for me, right?

Am I trying to go backwards here? What I'd like to do is go from my existing database to CRUD classes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一身骄傲 2024-10-02 17:04:27

如果您所做的只是创建了数据库,您可能需要考虑放弃该数据库并首先创建类,如 Alec 的选项 1 中所示。然后你可以让 NHibernate 为你生成数据库。

但为了回答你的问题,我总是从头开始创建模型/视图/控制器,因为我从来没有真正喜欢生成代码的输出。我相信 SharpArch 甚至计划废除 T4 模板,转而使用 Templify [来源] 因为它的问题。

If all you've done is created the database, you may want to consider scrapping that and creating the classes first as in option 1 from Alec. Then you can let NHibernate generate the database for you.

But to answer your question, I've always just created the models/views/controllers from scratch since I never really liked the output of generated code. I believe SharpArch is even planning on doing away with the T4 templates in favor of Templify [source] because of it's issues.

同尘 2024-10-02 17:04:27

如果您正在进行棕地开发(您就是这样),那么您可以采用以下两种方法之一:

  1. 手动创建实体/控制器/视图
  2. 使用脚手架生成器为您创建上述内容

根据您现有数据库的复杂程度,您将能够选择其中之一。如果您现有的数据库架构很复杂,并且字段名称不是您想要的实体名称,您可能需要使用选项 1 以及使用 ClassMap,而不是 Fluent NHibernate 的自动映射。

此外,根据您拥有的表数量以及它们的大小(字段数量),使用脚手架生成器可能仍然不是一个坏选择。为了让您了解一下,我曾多次遇到过使用相当大的医学数据库的棕地情况。它比我手动重新创建它们要快得多。

最后,您确实需要决定哪种方式对您来说更快以及哪种方式更相关。我们有一个非常强大的 S# 社区,因此获得一些支持不是问题。

If you are doing Brownfield development (which you are), then you can go one of two ways:

  1. Create the Entities / Controllers / Views manually
  2. Use the Scaffolding generator to create the above for you

Depending on how complex your existing database might be, you would be able to choose one over the other. If your existing database's schema is complex, has field names that are not what you would want in your entity you may want to go with option 1 as well as using ClassMaps instead of the automapping from Fluent NHibernate.

Also, depending on how many tables you have as well as how large they are (number of fields), using the Scaffolding Generator might still not be a bad option. To give you an idea, I've used to in a brownfield situation several times with rather large medical databases. It went much faster than me recreating those manually.

In the end, you really need to decide which way would be faster for you as well as which one would be more relevant. We have a pretty strong community with S# so getting some support is not an issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文