Servicestack: Handle indexes, auto increment etc without attributes?


I am testing <a href="https://github.com/ServiceStack/ServiceStack.OrmLite" rel="nofollow">OrmLite</a>, and I am looking at how to handle indexes in the tables that are created.

The only way that I have found if you want to mark something as an index, unique, auto_increment etc is via attributes, like this:

Index(Unique = true)] // Creates Unique Index public string Email { get; set; }

However, OrmLite/ServiceStack states that:

<blockquote> <ul><li>Map a POCO class 1:1 to an RDBMS table, cleanly by conventions, without any attributes required.</li> </ul></blockquote>

And I was thus hoping that there are other ways of defining these things without using attributes? The library with the class definitions should be completely separated from OrmLite.

Is this doable?

<hr />


The extension method AddAttributes does not seem to function for some reason:

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/ernFi.png" data-original="https://i.stack.imgur.com/ernFi.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


By convention, means that OrmLite will infer the schema from the model as can be expected. But if you want to add any customizations like adding an index on arbitrary fields, than you do need to tell OrmLite about them. As OrmLite is a code-first ORM, attributes are how to decorate additional functionality to your models.

In the next <strong>OrmLite v4</strong> you will be able to add these attributes decoupled from your POCO by adding them dynamically at startup, e.g:

typeof(Poco).GetProperty("Email") .AddAttributes(new IndexAttribute { Unique = true });

Which will have the same effect as decorating your property with [Index(Unique = true)]


  • Sending Bulk emails through phpmailer
  • passing items in two lists simultaneoulsy in each loop Jenkinsfile
  • How to open a tool window of a visual studio extension programmatically?
  • Where input value will be saved?
  • WCF Binding with both transport and message security
  • how to get a geom_segment show a legend
  • Substring strange Bounds? [duplicate]
  • Is there a way to have my app push its icon to other apps?
  • Problems with error: “Access to the path is denied.”
  • IE 11 Script1002 Filter syntax error
  • NODE.JS - how to handle a mix of OS and URL-style “paths” correctly?
  • Is steady_clock monotonic across threads?
  • Could copy unsigned int bit values as float but float value not returned to the caller function corr
  • How to extract details from the xml files using java?
  • Chaining Requests using BlueBird/ Request-Promise
  • How to receive GCM message when app is closed or in background?
  • Textarea v-model initial value with VueJS and Laravel
  • Python Equivalent of Java's 'Keystore'?
  • javax.net.ssl.SSLException: SSL handshake aborted Connection reset by peer while calling webservice
  • git clone, upload-pack out of memory
  • Javascript inside HTML import not affecting imported HTML
  • playing mp3 from nsbundle
  • How to check if a database and tables exist in sql server in a vb .net project?
  • How to create subsets of a single set of elements with XSLT?
  • Rotating Towards Path in OpenGL
  • Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?
  • Android: Unable to detect vertical plane
  • How to change user identity when git pushing via ssh?
  • Send array to next viewcontroller iOs xcode [duplicate]
  • Debug `Unexpected end of JSON input Error` on content script
  • Apple Mach-O Linker error (“duplicate symbol”)
  • Codeigniniter insert data through models and controller
  • Angular FormGroup won't update it's value immediately after patchValue or setValue
  • PHP Permalinks.. how to change?
  • What does the “id” field in an Android “Google Play Music” broadcast intent correspond to?
  • Creating random wired topology for given arbitrary number of nodes on NS2