NMemory provides a class TableCollection which represents a collection of the tables in a database. TableCollection.Create method initializes a database table and it takes two arguments.
- primaryKey: An IKeyInfo object that represents the primary key of the entities.
- identitySpecification: An IdentitySpecification to set an identity field.
If your class is inherited from the Database class, call Create method in your class constructor.
Now when object is created of MyDatabase class, then it will also create two tables in that in-memory database,
To create an identity column in a table, pass IdentitySpecification object in the second argument of Create method. IdentitySpecification constructor takes three arguments
- identityColumn: Property field which needs to be identity column in a table.
- seed: Is the value that is used for the very first row loaded into the table.
- increment: Is the incremental value that is added to the identity value of the previous row that was loaded.