{"action":"created","issue":{"url":"https://api.github.com/repos/npgsql/npgsql/issues/1880","repository_url":"https://api.github.com/repos/npgsql/npgsql","labels_url":"https://api.github.com/repos/npgsql/npgsql/issues/1880/labels{/name}","comments_url":"https://api.github.com/repos/npgsql/npgsql/issues/1880/comments","events_url":"https://api.github.com/repos/npgsql/npgsql/issues/1880/events","html_url":"https://github.com/npgsql/npgsql/issues/1880","id":311991729,"number":1880,"title":"Saving entities with ef6 and Npgsql 4.0","user":{"login":"naigsa","id":15928428,"avatar_url":"https://avatars1.githubusercontent.com/u/15928428?v=4","gravatar_id":"","url":"https://api.github.com/users/naigsa","html_url":"https://github.com/naigsa","followers_url":"https://api.github.com/users/naigsa/followers","following_url":"https://api.github.com/users/naigsa/following{/other_user}","gists_url":"https://api.github.com/users/naigsa/gists{/gist_id}","starred_url":"https://api.github.com/users/naigsa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naigsa/subscriptions","organizations_url":"https://api.github.com/users/naigsa/orgs","repos_url":"https://api.github.com/users/naigsa/repos","events_url":"https://api.github.com/users/naigsa/events{/privacy}","received_events_url":"https://api.github.com/users/naigsa/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-06T14:13:14Z","updated_at":"2018-04-08T10:31:41Z","closed_at":"2018-04-08T10:31:41Z","author_association":"NONE","body":"### Before submitting\r\n\r\nError when saving new entity.\r\n\r\n### Steps to reproduce\r\nContext\r\n```\r\npublic class CmsDbContext : DbContext\r\n    {\r\n        public CmsDbContext() : baseConnectionStringName)\r\n        {\r\n        }\r\n\r\n        protected override void OnModelCreating(DbModelBuilder modelBuilder)\r\n        {\r\n            modelBuilder.Entity<EntityDto>();\r\n\r\n            base.OnModelCreating(modelBuilder);\r\n        }\r\n    }\r\n```\r\nTable created using automigration with entity:\r\n\r\n```\r\n[Table(\"entities\")]\r\npublic class EntityDto \r\n{\r\n    [Column(\"id\")]\r\n    [JsonProperty(\"id\")]\r\n    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]\r\n    public Guid Id { get; set; }\r\n\r\n    [Column(\"alias\")]\r\n    [Index(IsUnique = true)]\r\n    public string Alias { get; set; }\r\n\r\n    [Column(\"name\")]\r\n    public string Name { get; set; }\r\n\r\n    [Column(\"display\")]\r\n    public string Display { get; set; }\r\n\r\n    [Column(\"dbtable\")]\r\n    public string DbTable { get; set; }\r\n\r\n    [Column(\"assembly\")]\r\n    public long Assembly { get; set; }\r\n\r\n    [Column(\"autogenerated\")]\r\n    public bool Autogenerated { get; set; }\r\n}\r\n```\r\n\r\nCreate new entity, attach to context and save\r\n\r\n### The issue\r\nExcpetion on SaveAsync():\r\n\r\n```\r\n\"ClassName\": \"System.Data.Entity.Infrastructure.DbUpdateException\",\r\n        \"Message\": \"An error occurred while updating the entries. See the inner exception for details.\",\r\n        \"Data\": null,\r\n        \"InnerException\": {\r\n            \"ClassName\": \"System.Data.Entity.Core.UpdateException\",\r\n            \"Message\": \"An error occurred while updating the entries. See the inner exception for details.\",\r\n            \"Data\": null,\r\n            \"InnerException\": {\r\n                \"ClassName\": \"System.NotSupportedException\",\r\n                \"Message\": \"Parameters with NpgsqlDbType.Unknown are no longer supported. If you're writing enums as strings, see the section on unmapped enums in the documentation.\",\r\n                \"Data\": null,\r\n                \"InnerException\": null,\r\n                \"HelpURL\": null,\r\n                \"StackTraceString\": \"   в Npgsql.TypeHandlers.UnknownTypeHandler.ValidateObjectAndGetLength(Object value, NpgsqlLengthCache& lengthCache, NpgsqlParameter parameter)\\r\\n   в Npgsql.NpgsqlParameter.ValidateAndGetLength()\\r\\n   в Npgsql.NpgsqlCommand.ValidateParameters()\\r\\n   в Npgsql.NpgsqlCommand.<ExecuteDbDataReader>d__101.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.<ExecuteAsync>d__0.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.<UpdateAsync>d__0.MoveNext()\",\r\n                \"RemoteStackTraceString\": null,\r\n                \"RemoteStackIndex\": 0,\r\n                \"ExceptionMethod\": \"8\\nValidateObjectAndGetLength\\nNpgsql, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7\\nNpgsql.TypeHandlers.UnknownTypeHandler\\nInt32 ValidateObjectAndGetLength(System.Object, Npgsql.NpgsqlLengthCache ByRef, Npgsql.NpgsqlParameter)\",\r\n                \"HResult\": -2146233067,\r\n                \"Source\": \"Npgsql\",\r\n                \"WatsonBuckets\": null\r\n            },\r\n            \"HelpURL\": null,\r\n            \"StackTraceString\": \"   в System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.<UpdateAsync>d__0.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Data.Entity.Core.Objects.ObjectContext.<ExecuteInTransactionAsync>d__3d`1.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStoreAsync>d__39.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesInternalAsync>d__31.MoveNext()\",\r\n            \"RemoteStackTraceString\": null,\r\n            \"RemoteStackIndex\": 0,\r\n            \"ExceptionMethod\": \"8\\nMoveNext\\nEntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\nSystem.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator+<UpdateAsync>d__0\\nVoid MoveNext()\",\r\n            \"HResult\": -2146233087,\r\n            \"Source\": \"EntityFramework\",\r\n            \"WatsonBuckets\": null\r\n        },\r\n        \"HelpURL\": null,\r\n        \"StackTraceString\": \"   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\r\\n   в Beeline.Cms.Dal.Repositories.BaseEfRepository`1.<SaveAsync>d__13.MoveNext() в C:\\\\Projects\\\\Badmin\\\\Beeline.Cms.Dal\\\\Repositories\\\\BaseEfRepository.cs:строка 87\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\r\\n   в Beeline.Cms.Dal.Repositories.BaseCacheEfRepository`1.<SaveAsync>d__9.MoveNext() в C:\\\\Projects\\\\Badmin\\\\Beeline.Cms.Dal\\\\Repositories\\\\BaseCacheEfRepository.cs:строка 56\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\r\\n   в Beeline.Cms.Domain.Services.EntityService.<InsertEntityAsync>d__5.MoveNext() в C:\\\\Projects\\\\Badmin\\\\Beeline.Cms.Domain\\\\Services\\\\EntityService.cs:строка 46\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\r\\n   в Beeline.Cms.Api.Controllers.EntityController.<SaveEntity>d__5.MoveNext() в C:\\\\Projects\\\\Badmin\\\\Beeline.Cms.Api\\\\Controllers\\\\EntityController.cs:строка 97\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__1`1.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\\r\\n--- Конец трассировка стека из предыдущего расположения, где возникло исключение ---\\r\\n   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   в System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()\",\r\n        \"RemoteStackTraceString\": null,\r\n        \"RemoteStackIndex\": 0,\r\n        \"ExceptionMethod\": \"8\\nThrow\\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\nSystem.Runtime.ExceptionServices.ExceptionDispatchInfo\\nVoid Throw()\",\r\n        \"HResult\": -2146233087,\r\n        \"Source\": \"mscorlib\",\r\n        \"WatsonBuckets\": null,\r\n        \"SafeSerializationManager\": {\r\n            \"m_serializedStates\": [\r\n                {\r\n                    \"InvolvesIndependentAssociations\": false\r\n                }\r\n            ]\r\n        },\r\n        \"CLR_SafeSerializationManager_RealType\": \"System.Data.Entity.Infrastructure.DbUpdateException, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"    \r\n```\r\n\r\n### Further technical details\r\n\r\nNet Framework: 4.6.1\r\nEntityFramework: 6.2.0\r\nNpgsql version: 4.0.0-preview1\r\nPostgreSQL version: 9.6.1\r\nOperating system: windows 7\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/npgsql/npgsql/issues/comments/379539472","html_url":"https://github.com/npgsql/npgsql/issues/1880#issuecomment-379539472","issue_url":"https://api.github.com/repos/npgsql/npgsql/issues/1880","id":379539472,"user":{"login":"roji","id":1862641,"avatar_url":"https://avatars0.githubusercontent.com/u/1862641?v=4","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"created_at":"2018-04-08T10:31:41Z","updated_at":"2018-04-08T10:31:41Z","author_association":"OWNER","body":"Fixed this for 4.0.0-preview2, thanks for raising."}}
{"actor":{"display_login":"roji"}}