Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do model-first ORM mapping with ServiceStack and OrmLite?

I'm just discovering ServiceStack for the first time this weekend and I find it completely amazing. As such, I'm already in the process of converting all of my projects over to it. Then I ran into a small snag.

I can't find any documentation that mentions using OrmLite starting with the database first and then mapping an existing schema into POCOs.

I've found plenty of material on code-first, but nothing on model-first.

Is there a way to use OrmLiite taking a model-first approach?

Thank you.

like image 525
TMc Avatar asked Oct 22 '22 20:10

TMc


1 Answers

OrmLite is primarily a code-first ORM, but if you want to start with an existing database you would just create a POCO with properties that maps 1:1 to an existing Table and columns.

It's trivial to infer a POCO manually, but if you want some code-gen tool to help do this, OrmLite includes a couple of T4 scripts you could use instead.

like image 83
mythz Avatar answered Oct 25 '22 19:10

mythz