简体   繁体   English

如何使用PetaPoco或NPoco生成DDL?

[英]How to generate DDL using PetaPoco or NPoco?

I have just started using PetaPoco/NPoco in one of my projects and have to say that it rocks however, It seems that the library is not able to generate DDL and create a table based on the Poco. 我刚开始在我的一个项目中使用PetaPoco / NPoco并且不得不说它摇滚,但似乎该库无法生成DDL并创建基于Poco的表。 I know that OrmLite can do this. 我知道OrmLite可以做到这一点。

Is there a way/workaround that can be used to for example decorate the poco and then based on the attributes DBMS specific table scripts are generated? 是否有一种方法/解决方法可用于例如装饰poco,然后根据属性生成DBMS特定的表脚本? eg Oracle, MSSql etc. 例如Oracle,MSSql等

Thank you 谢谢

No. PetaPoco seems (rightly) intent on staying small and lightweight, focusing on one thing (mapping between objects and IDb* concepts) and doing that well. 不,PetaPoco似乎(正确地)意图保持小巧轻便,专注于一件事(在物体和IDb *概念之间进行映射)并做得很好。

I could see this feature being semi-useful when running unit tests or very useful for prototyping, but IMO you want a DB migration manager to handle updates to your DB schema over time. 我可以看到这个功能在运行单元测试时非常有用,或者对于原型设计非常有用,但IMO希望数据库迁移管理器能够随着时间的推移处理数据库模式的更新。 Fluent Migrator is a good choice. 流利的Migrator是一个不错的选择。

For me, it's about a separation of where we are (current PetaPoco / NPoco classes) and how we got here (migrations). 对我而言,它是关于我们所处的位置(当前的PetaPoco / NPoco类)以及我们如何到达这里(迁移)。

Not sure exactly what you are after, but we use NPoco.T4 to generate our models from DB. 不确定你到底是什么,但我们使用NPoco.T4从DB生成我们的模型。 Maybe look into it. 也许看看吧。 You can find it on Nuget. 你可以在Nuget上找到它。

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

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