{"action":"created","issue":{"url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351","repository_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql","labels_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351/labels{/name}","comments_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351/comments","events_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351/events","html_url":"https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351","id":249815009,"number":351,"title":" An exception occurred while reading a database value. The expected type was 'System.Byte[]' but the actual value was of type 'System.DateTime'.","user":{"login":"tokaika","id":14201898,"avatar_url":"https://avatars0.githubusercontent.com/u/14201898?v=4","gravatar_id":"","url":"https://api.github.com/users/tokaika","html_url":"https://github.com/tokaika","followers_url":"https://api.github.com/users/tokaika/followers","following_url":"https://api.github.com/users/tokaika/following{/other_user}","gists_url":"https://api.github.com/users/tokaika/gists{/gist_id}","starred_url":"https://api.github.com/users/tokaika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tokaika/subscriptions","organizations_url":"https://api.github.com/users/tokaika/orgs","repos_url":"https://api.github.com/users/tokaika/repos","events_url":"https://api.github.com/users/tokaika/events{/privacy}","received_events_url":"https://api.github.com/users/tokaika/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-08-12T14:24:17Z","updated_at":"2017-08-22T14:26:31Z","closed_at":null,"body":"Prevents concurrent fields from being automatically cannot  identified\r\n\r\n```c#\r\nnamespace Sky.Model.Domain\r\n{\r\n    public class Category \r\n    {\r\n        public Guid Id { get; set; }\r\n\r\n    \r\n        public Guid ParentId { get; set; }\r\n\r\n   \r\n        public string CategoryName { get; set; }\r\n\r\n    \r\n        public Int64 ChildCount { get; set; }\r\n\r\n\r\n    \r\n        public DateTime DateCreated { get; set; }\r\n\r\n\r\n        public byte[] RowVersion { get; set; }\r\n\r\n\r\n    }\r\n\r\n\r\nnamespace Sky.Core.Mapping\r\n{\r\n    public class CategoryMap\r\n    {\r\n        public static void Map(EntityTypeBuilder<Category> builder)\r\n        {\r\n            builder.ToTable(\"Category\");\r\n            builder.HasKey(o => o.Id);\r\n            builder.Property(o => o.Id).IsRequired().HasMaxLength(36);\r\n            builder.Property(o => o.ParentId).IsRequired().HasMaxLength(36).IsUnicode(false);\r\n            builder.Property(o => o.CategoryName).HasMaxLength(64).IsRequired();\r\n            builder.HasIndex(o => o.CategoryName);\r\n            builder.Property(o => o.ChildCount).IsRequired();\r\n            builder.Property(o => o.DateCreated).IsRequired();\r\n          builder.Property(o => o.RowVersion).IsRequired().IsRowVersion().ValueGeneratedOnAddOrUpdate();\r\n        }\r\n    }\r\n}\r\n}\r\n```\r\n\r\n\r\nwhen  a  insert data。。。\r\n1.InvalidOperationException: An exception occurred while reading a database value. The expected type was 'System.Byte[]' but the actual value was of type 'System.DateTime'.\r\n\r\n2.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.Byte[]'.\r\n\r\n```c#\r\n var category1 = new Category\r\n                {\r\n                    CategoryName = \"News\",\r\n                    ChildCount = 0,\r\n                    ParentId = Guid.Empty,\r\n                    DateCreated = DateTime.UtcNow\r\n                };\r\n _context.Categories.Add(category1);\r\n  _context.SaveChanges();\r\n```\r\n\r\n\r\nlogger  ：sql\r\n```\r\n2017-08-12 21:39:28.1219|Microsoft.EntityFrameworkCore.Database.Command|INFO|Executed DbCommand (21ms) [Parameters=[@p0='?', @p2='?' (Size = 64), @p4='?', @p6='?', @p8='?', @p12='?', @p14='?' (Size = 64), @p16='?', @p18='?', @p20='?', @p24='?', @p26='?' (Size = 64), @p28='?', @p30='?', @p32='?', @p36='?', @p38='?' (Size = 64), @p40='?', @p42='?', @p44='?', @p48='?', @p50='?' (Size = 64), @p52='?', @p54='?', @p56='?', @p60='?', @p62='?' (Size = 64), @p64='?', @p66='?', @p68='?', @p72='?', @p74='?' (Size = 64), @p76='?', @p78='?', @p80='?', @p84='?', @p86='?' (Size = 64), @p88='?', @p90='?', @p92='?', @p96='?', @p98='?' (Size = 64), @p100='?', @p102='?', @p104='?', @p108='?', @p110='?' (Size = 64), @p112='?', @p114='?', @p116='?', @p120='?', @p122='?' (Size = 64), @p124='?', @p126='?', @p128='?', @p132='?', @p134='?' (Size = 64), @p136='?', @p138='?', @p140='?', @p144='?', @p146='?' (Size = 64), @p148='?', @p150='?', @p152='?', @p156='?', @p158='?' (Size = 64), @p160='?', @p162='?', @p164='?', @p168='?', @p170='?' (Size = 64), @p172='?', @p174='?', @p176='?', @p180='?', @p182='?' (Size = 64), @p184='?', @p186='?', @p188='?', @p192='?', @p194='?' (Size = 64), @p196='?', @p198='?', @p200='?', @p204='?', @p206='?' (Size = 64), @p208='?', @p210='?', @p212='?', @p216='?', @p218='?' (Size = 64), @p220='?', @p222='?', @p224='?', @p228='?', @p230='?' (Size = 64), @p232='?', @p234='?', @p236='?', @p240='?', @p242='?' (Size = 64), @p244='?', @p246='?', @p248='?', @p252='?', @p254='?' (Size = 64), @p256='?', @p258='?', @p260='?', @p264='?', @p266='?' (Size = 64), @p268='?', @p270='?', @p272='?', @p276='?', @p278='?' (Size = 64), @p280='?', @p282='?', @p284='?', @p288='?', @p290='?' (Size = 64), @p292='?', @p294='?', @p296='?'], CommandType='Text', CommandTimeout='0']\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p0, @p2, @p4, @p6, @p8);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p0;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p12, @p14, @p16, @p18, @p20);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p12;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p24, @p26, @p28, @p30, @p32);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p24;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p36, @p38, @p40, @p42, @p44);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p36;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p48, @p50, @p52, @p54, @p56);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p48;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p60, @p62, @p64, @p66, @p68);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p60;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p72, @p74, @p76, @p78, @p80);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p72;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p84, @p86, @p88, @p90, @p92);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p84;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p96, @p98, @p100, @p102, @p104);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p96;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p108, @p110, @p112, @p114, @p116);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p108;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p120, @p122, @p124, @p126, @p128);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p120;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p132, @p134, @p136, @p138, @p140);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p132;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p144, @p146, @p148, @p150, @p152);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p144;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p156, @p158, @p160, @p162, @p164);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p156;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p168, @p170, @p172, @p174, @p176);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p168;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p180, @p182, @p184, @p186, @p188);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p180;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p192, @p194, @p196, @p198, @p200);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p192;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p204, @p206, @p208, @p210, @p212);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p204;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p216, @p218, @p220, @p222, @p224);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p216;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p228, @p230, @p232, @p234, @p236);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p228;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p240, @p242, @p244, @p246, @p248);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p240;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p252, @p254, @p256, @p258, @p260);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p252;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p264, @p266, @p268, @p270, @p272);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p264;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p276, @p278, @p280, @p282, @p284);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p276;\r\nINSERT INTO `Category` (`Id`, `CategoryName`, `ChildCount`, `DateCreated`, `ParentId`)\r\nVALUES (@p288, @p290, @p292, @p294, @p296);\r\nSELECT `RowVersion` FROM `Category` WHERE `Id` = @p288; \r\n2017-08-12 21:39:28.3123|Microsoft.EntityFrameworkCore.Update|ERROR|An exception occurred in the database while saving changes for context type 'Sky.Core.SkyDbContext'.\r\nMicrosoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.InvalidOperationException: An exception occurred while reading a database value. The expected type was 'System.Byte[]' but the actual value was of type 'System.DateTime'. ---> System.InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.Byte[]'.\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.WrappedMySqlDataReader.ConvertWithReflection[T](Int32 ordinal, InvalidCastException e)\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.WrappedMySqlDataReader.GetFieldValue[T](Int32 ordinal)\r\n   at lambda_method(Closure , DbDataReader )\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.EntityFrameworkCore.Metadata.Internal.EntityMaterializerSource.ThrowReadValueException[TValue](Exception exception, Object value, IPropertyBase property)\r\n   at lambda_method(Closure , DbDataReader )\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.TypedRelationalValueBufferFactory.Create(DbDataReader dataReader)\r\n   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithPropagation(Int32 commandIndex, DbDataReader reader)\r\n   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(DbDataReader reader)\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.Consume(DbDataReader reader)\r\n   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)\r\n   at Microsoft.EntityFrameworkCore.Update.Internal.MySqlBatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)\r\n   at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IReadOnlyList`1 entries)\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList`1 entriesToSave)\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)\r\n   at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) An error occurred while updating the entries. See the inner exception for details.\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/comments/324043304","html_url":"https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351#issuecomment-324043304","issue_url":"https://api.github.com/repos/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/351","id":324043304,"user":{"login":"souchprod","id":8854025,"avatar_url":"https://avatars0.githubusercontent.com/u/8854025?v=4","gravatar_id":"","url":"https://api.github.com/users/souchprod","html_url":"https://github.com/souchprod","followers_url":"https://api.github.com/users/souchprod/followers","following_url":"https://api.github.com/users/souchprod/following{/other_user}","gists_url":"https://api.github.com/users/souchprod/gists{/gist_id}","starred_url":"https://api.github.com/users/souchprod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/souchprod/subscriptions","organizations_url":"https://api.github.com/users/souchprod/orgs","repos_url":"https://api.github.com/users/souchprod/repos","events_url":"https://api.github.com/users/souchprod/events{/privacy}","received_events_url":"https://api.github.com/users/souchprod/received_events","type":"User","site_admin":false},"created_at":"2017-08-22T14:26:31Z","updated_at":"2017-08-22T14:26:31Z","body":"For the record, i also reproduce this bug with SByte (generated from scaffoding, with a column type: tinyint(1)). In this case the error raised is \r\n\r\n`\r\nAn exception occurred while reading a database value. The expected type was 'System.Nullable`1[System.SByte]' but the actual value was of type 'System.Boolean'.\r\nInvalidCastException: Unable to cast object of type 'System.Boolean' to type 'System.SByte\r\n'\r\n\r\nwith the same stacktrace.\r\n\r\nI am working on it.\r\n`"}}
{"actor":{"display_login":"souchprod"}}