Copied to clipboard

Flag this post as spam?

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


  • Andrei Canef 33 posts 84 karma points
    Dec 11, 2014 @ 11:12
    Andrei Canef
    0

    Error creating database tables via API

    I'm developing locally using an Umbraco 7.1.8 installation running on SQL CE. 

    When trying to create some tables to hold my POCOs, I get a "Sequence contains no matching element"error . The code is pretty simple, and runs on ApplicationStarted: 

    var db = applicationContext.DatabaseContext.Database;
    if (!db.TableExist("PortalMessage"))
                {
                    db.CreateTable(true);
                }

    Error message attached:

    Any ideas are much appreciated.

  • Alex Lindgren 159 posts 356 karma points
    Dec 11, 2014 @ 18:43
    Alex Lindgren
    0

    Just ran into the same error except my create call is:

    db.CreateTable<MyPocoClass>();
    
  • Lewis 27 posts 90 karma points
    Jan 11, 2015 @ 11:20
    Lewis
    0

    Did you manage to resolve this? I'm also getting this error.

  • Alex Lindgren 159 posts 356 karma points
    Jan 12, 2015 @ 15:59
    Alex Lindgren
    0

    I ended up just creating it manually which was okay for now since I didn't need to have this happen more than once, but I'd like to know how so we can create reusable modules.

  • Andrei Canef 33 posts 84 karma points
    Jan 12, 2015 @ 18:26
    Andrei Canef
    101

    The issue I had was that the POCO object I was basing my table on had a property which couldn't be reduced to a simple type. I think it was a list, or something similar, and because of that the database creation was just falling over (with a less-than-informative message:) )

     

    Not sure if it's the same issue you guys are encountering. 

  • Iain Martin 54 posts 98 karma points
    Sep 20, 2017 @ 10:05
    Iain Martin
    0

    I know this is an old topic, but I had the same issue - I had used HtmlString as one of my property types and PetaPoco balked at that, changed it back to a normal string and all was well again.

    It's obvious when you know why, but I agree the error message is less than helpful.

  • Nick Hoang 52 posts 182 karma points c-trib
    Nov 28, 2018 @ 09:29
    Nick Hoang
    0

    In my case is because of I was used enum for some properties, remove enum and use int instead will resolve the issue.

    And here's how to use enum: https://stackoverflow.com/questions/28633162/create-database-table-from-model-with-enum-using-umbraco-core-persistence/32354078

    Cheers Nick

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies