Sequence contains no matching element when using Npgsql from Nuget and EntityFramework 6

1,076 views
Skip to first unread message

even...@trioptimum.ru

unread,
Aug 31, 2014, 7:52:51 AM8/31/14
to npgsq...@googlegroups.com
Hello!

I installed pgsql instead of SqlServer on a working Mvc ASP.NET website, I migrated the database... But now when I try to launch it with Npgsql, I get

System.InvalidOperationException
Sequence contains no matching element

The only queries which are getting executed on the Postgresql side are:
2014-08-31 15:49:39 MSK [29105-1] postgres@dm3 LOG: statement: SET extra_float_digits=3;SET ssl_renegotiation_limit=0;
2014-08-31 15:49:39 MSK [29105-2] postgres@dm3 LOG: statement: SET statement_timeout = 20000
2014-08-31 15:49:39 MSK [29105-3] postgres@dm3 LOG: statement: SELECT typname, oid FROM pg_type WHERE typname IN ('oidvector', '_oidvector', 'unknown', '_unknown', 'refcursor', '_refcursor', 'char', '_char', 'bpchar', '_bpchar', 'varchar', '_varchar', 'text', '_text', 'name', '_name', 'bytea', '_bytea', 'bit', '_bit', 'bool', '_bool', 'int2', '_int2', 'int4', '_int4', 'int8', '_int8', 'oid', '_oid', 'float4', '_float4', 'float8', '_float8', 'numeric', '_numeric', 'inet', '_inet', 'macaddr', '_macaddr', 'money', '_money', 'point', '_point', 'lseg', '_lseg', 'path', '_path', 'box', '_box', 'circle', '_circle', 'polygon', '_polygon', 'uuid', '_uuid', 'xml', '_xml', 'interval', '_interval', 'date', '_date', 'time', '_time', 'timetz', '_timetz', 'timestamp', '_timestamp', 'abstime', '_abstime', 'timestamptz', '_timestamptz')
2014-08-31 15:49:39 MSK [29105-4] postgres@dm3 LOG: statement: DISCARD ALL

So it is probably a problem with the Npgsql... Or something.

Please help!

Emil Lenngren

unread,
Aug 31, 2014, 7:56:07 AM8/31/14
to even...@trioptimum.ru, npgsq...@googlegroups.com

Hi. What version of Postgresql and Npgsql are you running? Could you print a full stack trace of the exception?

--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/npgsql-help/700cadbe-e9d4-4b21-9898-76bc017e55fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

even...@trioptimum.ru

unread,
Aug 31, 2014, 8:16:29 AM8/31/14
to npgsq...@googlegroups.com, even...@trioptimum.ru
Hello! Thanks for that quick answer.
I am using Npgsql with Npgsql.EntityFramework from NuGet, it is version 2.1.3 (both)
The postgresql version is 9.4beta2
THe full stacktrace is:
[InvalidOperationException: Sequence contains no matching element]
System.Linq.Enumerable.Single(IEnumerable`1 source, Func`2 predicate) +2534009
System.Data.Entity.Utilities.DbProviderManifestExtensions.GetStoreTypeFromName(DbProviderManifest providerManifest, String name) +146
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(EdmProperty column, EntityType table, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration) +650
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.<>c__DisplayClass1.<Configure>b__0(Tuple`2 pm) +125
System.Data.Entity.Utilities.IEnumerableExtensions.Each(IEnumerable`1 ts, Action`1 action) +194
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(IEnumerable`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration) +158
System.Data.Entity.ModelConfiguration.Configuration.Types.StructuralTypeConfiguration.ConfigurePropertyMappings(IList`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride) +278
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigurePropertyMappings(DbDatabaseMapping databaseMapping, EntityType entityType, DbProviderManifest providerManifest, Boolean allowOverride) +728
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) +203
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) +661
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) +464
System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) +570
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +103
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +143
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +171
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +594
System.Data.Entity.Internal.InternalContext.Initialize() +31
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +137
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +38
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +99
System.Linq.Queryable.OrderByDescending(IQueryable`1 source, Expression`1 keySelector) +66
ArticleServices.Implementation.ArticleService.Select(Int32 number) +321
Classic.Views.Home.HomeViewModelBuilder.Build() in d:\DM3\DMFront\Classic\Views\Home\HomeViewModelBuilder.cs:36
Classic.Controllers.HomeController.Index() in d:\DM3\DMFront\Classic\Controllers\HomeController.cs:22
lambda_method(Closure , ControllerBase , Object[] ) +101
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690172
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155


воскресенье, 31 августа 2014 г., 15:56:07 UTC+4 пользователь Emil Lenngren написал:

even...@trioptimum.ru

unread,
Aug 31, 2014, 9:12:42 AM8/31/14
to npgsq...@googlegroups.com, even...@trioptimum.ru
Also tried with Pgsql server 9.1 - same thing

воскресенье, 31 августа 2014 г., 15:56:07 UTC+4 пользователь Emil Lenngren написал:

even...@trioptimum.ru

unread,
Aug 31, 2014, 9:47:43 AM8/31/14
to npgsq...@googlegroups.com, even...@trioptimum.ru
Seems like it can't find the "_unknown" type...

Francisco Figueiredo Jr.

unread,
Aug 31, 2014, 10:23:59 AM8/31/14
to even...@trioptimum.ru, npgsq...@googlegroups.com
Hi, Evengard!

If you run the query: SELECT typname, oid FROM pg_type WHERE typname
IN ('oidvector', '_oidvector', 'unknown', '_unknown', 'refcursor',
'_refcursor', 'char', '_char', 'bpchar', '_bpchar', 'varchar',
'_varchar', 'text', '_text', 'name', '_name', 'bytea', '_bytea',
'bit', '_bit', 'bool', '_bool', 'int2', '_int2', 'int4', '_int4',
'int8', '_int8', 'oid', '_oid', 'float4', '_float4', 'float8',
'_float8', 'numeric', '_numeric', 'inet', '_inet', 'macaddr',
'_macaddr', 'money', '_money', 'point', '_point', 'lseg', '_lseg',
'path', '_path', 'box', '_box', 'circle', '_circle', 'polygon',
'_polygon', 'uuid', '_uuid', 'xml', '_xml', 'interval', '_interval',
'date', '_date', 'time', '_time', 'timetz', '_timetz', 'timestamp',
'_timestamp', 'abstime', '_abstime', 'timestamptz', '_timestamptz')

in your server, does it return any error?

Also, do you think you could create a simple application which
reproduces your problem?
If you could create a simple console application it would be even
better because it would be easier to convert to Nunit test case and
add it to our testsuite.

Thanks in advance.


On 8/31/14, even...@trioptimum.ru <even...@trioptimum.ru> wrote:
> Seems like it can't find the "_unknown" type...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Npgsql Help" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to npgsql-help...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/npgsql-help/fdebbd95-60e6-4de1-be2e-db7b0ba4cc83%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


--
Regards,

Francisco Figueiredo Jr.
Npgsql Lead Developer
http://www.npgsql.org
http://gplus.to/franciscojunior
http://fxjr.blogspot.com
http://twitter.com/franciscojunior

Emil Lenngren

unread,
Aug 31, 2014, 11:05:30 AM8/31/14
to Evengard E., npgsq...@googlegroups.com
There seems to be a problem with your model and which datatypes it uses. Did you create it for use with PostgreSQL or did you take a model designed for SQL Server and migrated it for use with PostgreSQL?
Which datatypes do you use in your model?


2014-08-31 15:47 GMT+02:00 <even...@trioptimum.ru>:
Seems like it can't find the "_unknown" type...
--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.

even...@trioptimum.ru

unread,
Aug 31, 2014, 11:30:25 AM8/31/14
to npgsq...@googlegroups.com, even...@trioptimum.ru, fran...@npgsql.org
воскресенье, 31 августа 2014 г., 18:23:59 UTC+4 пользователь Francisco Figueiredo Jr. написал:
It returns no errors, and it returns 71 rows, instead of 72. I tried to add the missing "_unknown", but that changed nothing.

By the way, I tried the 2.2.0rc2 Npgsql - it gave me the exact same error.

It is weird, when trying to create the small testcase I don't get that error. It does exactly the same that it should do with the main app, so I suppose the model is pretty OK. I can't understand the roots of the problem.

ambor...@gmail.com

unread,
Sep 12, 2014, 6:05:29 AM9/12/14
to npgsq...@googlegroups.com, even...@trioptimum.ru, fran...@npgsql.org
Hello!
Did you managed to workaround this somehow?
Currently I`m expiriencing problem with same observed effects.

Cheers, Andrew.

воскресенье, 31 августа 2014 г., 21:30:25 UTC+6 пользователь even...@trioptimum.ru написал:
> воскресенье, 31 августа 2014 г., 18:23:59 UTC+4 пользователь Francisco Figueiredo Jr. написал:
>
> > Hi, Evengard!
>
> >
>
> >
>
> >
>
> > If you run the query: SELECT typname, oid FROM pg_type WHERE typname
>
> >
>
> > IN ('oidvector', '_oidvector', 'unknown', '_unknown', 'refcursor',
>
> >
>
> > '_refcursor', 'char', '_char', 'bpchar', '_bpchar', 'varchar',
>
> >
>
> > '_varchar', 'text', '_text', 'name', '_name', 'bytea', '_bytea',
>
> >
>
> > 'bit', '_bit', 'bool', '_bool', 'int2', '_int2', 'int4', '_int4',
>
> >
>
> > 'int8', '_int8', 'oid', '_oid', 'float4', '_float4', 'float8',
>
> >
>
> > '_float8', 'numeric', '_numeric', 'inet', '_inet', 'macaddr',
>
> >
>
> > '_macaddr', 'money', '_money', 'point', '_point', 'lseg', '_lseg',
>
> >
>
> > 'path', '_path', 'box', '_box', 'circle', '_circle', 'polygon',
>
> >
>
> > '_polygon', 'uuid', '_uuid', 'xml', '_xml', 'interval', '_interval',
>
> >
>
> > 'date', '_date', 'time', '_time', 'timetz', '_timetz', 'timestamp',
>
> >
>
> > '_timestamp', 'abstime', '_abstime', 'timestamptz', '_timestamptz')
>
> >
>
> >
>
> >
>
> > in your server, does it return any error?
>
> >
>
> >
>
> >
>
> > Also, do you think you could create a simple application which
>
> >
>
> > reproduces your problem?
>
> >
>
> > If you could create a simple console application it would be even
>
> >
>
> > better because it would be easier to convert to Nunit test case and
>
> >
>
> > add it to our testsuite.
>
> >
>
> >
>
> >
>
> > Thanks in advance.
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > > Seems like it can't find the "_unknown" type...
>
> >
>
> > >
>
> >
>
> > > --
>
> >
>
> > > You received this message because you are subscribed to the Google Groups
>
> >
>
> > > "Npgsql Help" group.
>
> >
>
> > > To unsubscribe from this group and stop receiving emails from it, send an
>
> >
>
> >
>
> >
>

even...@trioptimum.ru

unread,
Sep 12, 2014, 6:21:41 AM9/12/14
to npgsq...@googlegroups.com, even...@trioptimum.ru
It seems like I had some misconfiguration or something like that. Well, we've done a lot of refactoring on our code, so I ported it from scratch. We made code configuration of Entity with NPgSql, and the problem dissapeared... Or actually never come back.

By the way, before the refactoring the connection was created on a per-request basis. I got a workaround by making a first connection to the DB in Application_Start - this is weird but it really helped.

PS: when doing the code configuration of EF with NPgSql beware - the NpgSql package in NuGet have a bug - even with the EF6 version NpgsqlServices class is private, when it should be public. You need to recompile it from scratch and add a define (apparently it seems to be some kind of bug in defines of the project - even building Release-EF6 doesn't set the define, still making it private)

воскресенье, 31 августа 2014 г., 15:52:51 UTC+4 пользователь even...@trioptimum.ru написал:

ambor...@gmail.com

unread,
Sep 12, 2014, 8:05:51 AM9/12/14
to npgsq...@googlegroups.com, even...@trioptimum.ru
Hi!

Thanks for details.

I've deleted all 'decimal' types from my model and now it works. Seems like there is a promlem with mapping of this type.

BTW I suppose there should not be '_unknown' in that list.

Regards, Andrey.

пятница, 12 сентября 2014 г., 16:21:41 UTC+6 пользователь even...@trioptimum.ru написал:

Shay Rojansky

unread,
Sep 12, 2014, 10:48:59 AM9/12/14
to npgsq...@googlegroups.com, even...@trioptimum.ru


On Friday, September 12, 2014 1:21:41 PM UTC+3, even...@trioptimum.ru wrote:

PS: when doing the code configuration of EF with NPgSql beware - the NpgSql package in NuGet have a bug - even with the EF6 version NpgsqlServices class is private, when it should be public. You need to recompile it from scratch and add a define (apparently it seems to be some kind of bug in defines of the project - even building Release-EF6 doesn't set the define, still making it private)

 This issue has already been fixed and will be included in the upcoming 2.2.1 release (see https://github.com/npgsql/Npgsql/pull/325).

E., Evengard

unread,
Sep 12, 2014, 11:04:59 AM9/12/14
to Shay Rojansky, npgsq...@googlegroups.com

That's exactly the problem - the define doesn't get applied from Master.

12 сент. 2014 г. 18:49 пользователь "Shay Rojansky" <ro...@roji.org> написал:
Reply all
Reply to author
Forward
0 new messages