简体   繁体   English

从Postgresql数据库ServiceStack.Ormlite生成类对象

[英]Generating Class Object from Postgresql Database ServiceStack.Ormlite

We are in the process of developing a brand new application. 我们正在开发一个全新的应用程序。

We want to use ASP.NET MVC 5 with ServiceStack.Ormlite. 我们希望将ASP.NET MVC 5与ServiceStack.Ormlite一起使用。

Also want to use Postgresql database to store relational objects / tables. 还想使用Postgresql数据库来存储关系对象/表。

Question: Is there a way / tool to generate C# Class Objects from the Postgresql Database which the ORM then can use to perform operations on the tables. 问题:是否有一种方法/工具可以从Postgresql数据库生成C#类对象,然后ORM可以使用它来对表执行操作。

EG I have a table called "Person" in the Database. EG我在数据库中有一个名为“Person”的表。

What I want to do is, using some tool (Need to know which tool) to generate the C# class object so I can use servicestack.ormlite to add a new person to the table. 我想要做的是,使用一些工具(需要知道哪个工具)来生成C#类对象,这样我就可以使用servicestack.ormlite向表中添加一个新人。

Then if I add a column to that table, I generate a new class to replace the old one. 然后,如果我向该表添加一列,我会生成一个新类来替换旧的。

Is that possible and which tool will allow me to do that? 这是可能的,哪种工具可以让我这样做?

OrmLite's primarily a code-first ORM but does have T4 Templates to help with initially generating the code-first POCO's for existing database tables. OrmLite主要是代码优先的ORM,但确实有T4模板来帮助最初生成现有数据库表的代码优先POCO。

Although after generating the POCO's, I'd be maintaining them (ie code-first) from that point forward. 虽然在生成POCO之后,我会从那时开始维护它们(即代码优先)。

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

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