Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dennis Pullens 8 posts 89 karma points
    Aug 26, 2019 @ 12:37
    Dennis Pullens
    0

    Non-fluent NPoco definition and alteration

    Hi all,

    Since v8 we've been using migrations to set up our tables. We started by executing the table definitions using Database.Execute, but now we want something tied to our code. We're looking into two options; the Create.Table<T>().Do()-way (I'll call it Definition-based for now) and the Create.Table("tableName").WithColumn()-way (Fluent).

    Although the Definition-based way looks quite promising, there are two drawbacks that keep us from using it and therefore leaning towards the Fluent option.

    1. We cannot find a way (attribute) to set the default value of a column. I looked in both UmbracoCms/src/Umbraco.Core/Persistence/DatabaseAnnotations as well as NPoco/src/NPoco, but no such attribute seems to exists. Is there a way to set the default value for a column?
    2. When using AlterColumn<TableDefinition> it seems attributes aren't take into account. I tested this by using the [NullSetting]-attribute. When using this attribute together with AlterColumn, the column remained 'not null', while using this attribute with the Create.Table makes it 'null'. Are we using it wrong, or is this a missing functionality in the AlterColumn method?

    Thank you for any answer in advance.

    Regards, Dennis

Please Sign in or register to post replies

Write your reply to:

Draft