Database First to SS ORMLite

Is there a documented process or example showing how to transition from an existing database into a ServiceStack ORMLite compliant project?
There are excellent videos showing the creation of CRUD applications and API’s from code-first, one showing a nice “Database First” approach using AutoQuery and GenerateCrudServices with Locode, but what if someone is taking an existing database and creating a simple API business layer?
For example, using something like LLBLGen as a POCO generator creates all of the definitions for various frameworks, but these are not appropriate for use with ORMLite as they don’t have the SS attributes for indexes, names, etc.
Is there a way to generate the fully attributed POCO’s to allow a one-time transition from DB-first to SS-POCO-first?

Hi @jsobell, did you try using the AutoGen Export functionality? This should give you your DB table models as well as the AutoQuery DTOs equivalent. This is designed to the that ‘one time’ task to transition to a code first approach.

We have an example of doing this process in a video as well. Let me know if this approach works or if you are looking for something different.

Thanks, yes, that video appears to be what I was looking for.
I guess I was surprised that the same DTO file contains both DTOs and the CRUD route types.

Thanks,
Jason

I got it working, although the lack of ability to generate view POCO’s is a pain.
Out of interest, is it possible to apply AutoQuery to any other ORM systems?
I.e. can it be applied as a Linq query against an existing Linq tree?

An older alternative (and one you can customize yourself) it to use a T4 template. Eg you could use this one as a starting point to further automate the generation of classes you need if you are dealing with problematic schemas.

As for other ORM systems, we don’t yet support any other ORMs, but in our Todo examples in some of our templates you will see AutoQuery used with other data source types like MemoryDataSource. In the docs we have a section on AutoQuery Datasources that you might find useful depending on how else you want to use it.

1 Like