简体   繁体   English

GenWise:为nHibernate生成往返代码

[英]GenWise: Round trip code generation for nHibernate

I have been experimenting with GenWise and CodeSmith. 我一直在尝试GenWise和CodeSmith。 I am looking for a tool that will: 我正在寻找一种工具,该工具将:

a) let me edit the data schema in SQL Server SSMS a)让我在SQL Server SSMS中编辑数据架构

b) generate all the C# objects, xml etc from the database b)从数据库生成所有C#对象,xml等

c) have lots of control over the genrated XML and C# c)对生成的XML和C#具有很多控制权

d) do the "right thing" when generating code so that I can use the tool iteratively. d)生成代码时做“正确的事”,以便我可以迭代地使用该工具。 ie round trip code generation, not just generate once or twice and then give up when I have to make manual changes. 即,生成往返代码,而不仅仅是生成一次或两次,然后在必须进行手动更改时放弃。

e) I DON'T want a solution that goes backward: write C# with annotations and generate the DB schema. e)我不需要落后的解决方案:编写带有注释的C#并生成数据库模式。 That IMO sucks and screws you when you need to fine tune the schema. 当您需要微调模式时,IMO会为您带来麻烦。 DB code should be driven from the DB schema upwards, not code downwards. 数据库代码应从数据库架构向上驱动,而不是向下驱动。

I have to say, it appears the GenWise does all of this. 我不得不说,GenWise似乎可以完成所有这一切。 Has anyone used it for an extended period of time involving iterating changes in the DB schema and regenerating code, while also customizing the business objects/logic in the code? 是否有人长时间使用它,涉及迭代数据库模式中的更改并重新生成代码,同时还自定义代码中的业务对象/逻辑?

I have used template based tools like CodeSmith or MyGeneration and I have also used tools, like LLBGen which I think is similar to GenWise althought I never used this one myself. 我曾经使用过基于模板的工具,例如CodeSmith或MyGeneration,也曾使用过工具,例如LLBGen,我认为它与GenWise类似,尽管我从未亲自使用过。

Personally I prefer template based tools. 我个人更喜欢基于模板的工具。 IMHO they give you a lot more control and the possibility to fine tune your generated code. 恕我直言,它们为您提供了更多控制权,并可以对生成的代码进行微调。 With tools like LLBgen my experience is a bit more limited, but I didn't like the fact that I didn't understand all generated code before I hit generate. 使用LLBgen之类的工具,我的经验会受到更多的限制,但是我不喜欢这样的事实,即在我点击generate之前我不理解所有生成的代码。 Tools like LLBGen will get the job done faster, but if you're a control freak and you want to know what the generated code does then you'll need to go through all generated code and understand how it works. 诸如LLBGen之类的工具可以更快地完成工作,但是如果您是控制狂,并且想知道生成的代码做什么,那么您将需要遍历所有生成的代码并了解其工作原理。

Btw I've moved from this approach to domain driven design a few years ago, but in a few cases I still find that generating code from the DB is a better solution. 顺便说一句,几年前我已经从这种方法转到领域驱动的设计,但是在某些情况下,我仍然发现从数据库生成代码是更好的解决方案。

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

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