Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.0-preview1 No suitable constructor found for entity type 'PostgisPoint', works with 2.0.1 . #338

Closed
summershrimp opened this issue Mar 11, 2018 · 7 comments

Comments

@summershrimp
Copy link

 Add-Migration AddEntities
System.InvalidOperationException: No suitable constructor found for entity type 'PostgisPoint'. The following parameters could not be bound to properties of the entity: 'x', 'y'.
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConstructorBindingConvention.Apply(InternalModelBuilder modelBuilder)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnModelBuilt(InternalModelBuilder modelBuilder)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.Internal.InternalAccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
   at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
No suitable constructor found for entity type 'PostgisPoint'. The following parameters could not be bound to properties of the entity: 'x', 'y'.
@roji
Copy link
Member

roji commented Mar 11, 2018

Can you please post some details on what triggered this? A minimal dbcontext + code would be great.

@lust4life
Copy link

lust4life commented Mar 13, 2018

maybe use postgisgeometry as the point type, or use a implicit constructor ?

https://docs.microsoft.com/en-us/ef/core/modeling/constructors
dotnet/efcore#10789

@PMExtra
Copy link

PMExtra commented Mar 15, 2018

@PMExtra
Copy link

PMExtra commented Mar 15, 2018

The class PostgisPoint doesn't have parameterless constructor.
But previous versions works fine with it.

@roji
Copy link
Member

roji commented Jun 10, 2018

Version 2.1.0 introduced support for NetTopologySuite as a way to access PostGIS types - it's a full-blown spatial library with more powerful types, and which also has spatial operations which Npgsql translates to PostGIS functions.

Unfortunately support for the legacy PostGIS types (e.g. PostgisPoint) was dropped from the EF Core provider, at least for now (note that at the ADO level support is still there).

Am going to close this issue for now (especially as no code sample was provided), but will consider reopening if there's a good reason to bring the legacy types to EF Core (and if more detail is added about this specific issue).

@roji roji closed this as completed Jun 10, 2018
@summershrimp
Copy link
Author

@danieldiazastudillo
Copy link

Just by adding a default (empty) constructor for some entities the error stops showing. Very weird. Any explanation for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants