Copied to clipboard

Flag this post as spam?

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


  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 10, 2021 @ 15:58
    Huw Reddick
    0

    Inserting data in custom table using migration

    I am trying to insert some rows into a custom table during the component migration but am getting the error below

    [BootFailedException: Boot failed: Umbraco cannot run. See Umbraco's log file for more details.
    
    -> Umbraco.Core.Exceptions.BootFailedException: Boot failed.
    
    -> System.Data.SqlServerCe.SqlCeException: The column name is not valid. [ Node name (if any) = ,Column name = Id ]
    

    Is this possible? If so what am I doing wrong?

    Here is the code I'm trying.

        if (TableExists("VantageConfig"))
        {
            var newrow1 = new VantageConfigDataSchema
            {
                Group = "1-CRM",
                Name = "CRMAddress",
                Label = "Dynamics Url",
                Type = 0
            };
            Insert.IntoTable("VantageConfig").Row(newrow1).Do();
    
    
        }
    

    This is my datascheme (used to create the table)

    public class VantageConfigDataSchema
    {
        [PrimaryKeyColumn(AutoIncrement = true, IdentitySeed = 1)]
        [NPoco.Column("C_ID")]
        public int Id { get; set; }
        [NPoco.Column("C_Name")]
        public string Name { get; set; }
        [NPoco.Column("C_Value")]
        public string Value { get; set; }
        [NPoco.Column("C_Label")]
        public string Label { get; set; }
        [NPoco.Column("C_Encrypted")]
        public bool Encrypted { get; set; }
        [NPoco.Column("C_GROUP")]
        public string Group { get; set; }
        [NPoco.Column("C_TYPE")]
        public int Type { get; set; }
    }
    
  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 12, 2021 @ 09:40
    Huw Reddick
    100

    After a lot of fiddling around I managed to get it to work by creating the row as below using a dynamic object, seems it wants the actual column names not the fields from the Npoco Class

            dynamic newrow1 = new 
            {
                C_Group = "1-CRM",
                C_Name = "CRMAddress",
                C_Label = "Dynamics Url",
                C_Encrypted = false,
                C_Type = 0,
                C_Value = String.Empty
            };
            Insert.IntoTable("VantageConfig").Row(newrow1).Do();
    
Please Sign in or register to post replies

Write your reply to:

Draft