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); }
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.
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.
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.
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:
Error message attached:
Any ideas are much appreciated.
Just ran into the same error except my create call is:
Did you manage to resolve this? I'm also getting this error.
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.
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.
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.
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
is working on a reply...