0

I am running PetaPoco template T4 on my database and it generates the following error:

Running transformation: System.InvalidOperationException: Sequence contains more than one     matching element

Reported from the file 'database.tt

My database is modeled correctly, however most of the tables have no records, although I tihnk that it's nothing to do with it, is it?

I'm querying a MySQL local database. I've setup the connection string in the web.config and this is the only connection string in the web.config file

Liron Harel
  • 10,819
  • 26
  • 118
  • 217

2 Answers2

1

Yesterday I had same issue, I also use MySQL and last Nuget package. First of all I found that generation works on all databases, I try solution from official page:

DatabaseName = "name";

But I found that it doesn't understand variable DatabaseName and now it called SchemaName. This fix errors on unknown tables.

Second I found that it throw exception on tables with multiple PK, so open Database.cs after T4 template compilation and check last table. My solution was to remove generation from primary key in PetaPoco.Generator.ttinclude and then manual editing.

Also, you can look at: In PetaPoco, how to decorate a table that has multi-columns primary keys

Community
  • 1
  • 1
webdeveloper
  • 17,174
  • 3
  • 48
  • 47
  • Michael Dimoudis took the time to rewrite the T4 templates to handle composite keys. Here's the repo -> https://github.com/michaeldimoudis/PetaPoco/tree/master/PetaPoco/Models/Generated – Rod Hartzell Jan 11 '16 at 17:05
0

Do you have more info, such as a stack trace ? VS usually goes to the location of the error for me, but initial errors sometimes crop up before the actual template parsing begins. You haven't accidentally made a second copy of the connectionstring in the config file ?

Ben McIntyre
  • 1,972
  • 17
  • 28