This project has moved and is read-only. For the latest updates, please go here.
1
Vote

SQL Server connection failing on 3.4

description

Hi there, I was testing the new version with use with Microsoft SQL Server and I can get data into Participants, Sessions and Status Updates no problem. This worked fine in 3.3, as well as the SQLite works fine, so I have a feeling that it has to do with it uniqueidentifier field in sql server.

However the insert query fails on Events fails stating the following...

Erorr occured while logging history.: System.InvalidOperationException: The 'Id' property on 'Session' could not be set to a 'System.Guid' value. You must set this property to a non-null value of type 'System.String'.
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader1.GetValue(DbDataReader reader, Int32 ordinal)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
at lambda_method(Closure , Shaper )
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func
2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
at lambda_method(Closure , Shaper )
at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator1.ReadNextElement(Shaper shaper)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper
1.SimpleEnumerator.MoveNext()
at System.Data.Entity.Internal.LazyEnumerator1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable1 sequence)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable
1 query, Expression queryRoot)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable1 source, Expression1 predicate)
at Squiggle.History.DAL.HistoryRepository.AddSessionEvent(String sessionId, DateTime stamp, EventType type, String sender, String senderName, IEnumerable1 recipients, String data) in c:\Projects\Visual Studio\Squiggle\Squiggle.History\DAL\HistoryRepository.cs:line 23
at Squiggle.History.HistoryManager.AddSessionEvent(String sessionId, EventType type, String senderId, String senderName, IEnumerable
1 recipients, String data) in c:\Projects\Visual Studio\Squiggle\Squiggle.History\HistoryManager.cs:line 25
at Squiggle.Client.Chat.<>c__DisplayClass2d.<LogHistory>b__2b(HistoryManager manager) in c:\Projects\Visual Studio\Squiggle\Squiggle.Client\Chat.cs:line 245
at Squiggle.Client.Chat.<>c__DisplayClass36.<DoHistoryAction>b__35() in c:\Projects\Visual Studio\Squiggle\Squiggle.Client\Chat.cs:line 278
at Squiggle.Utilities.ExceptionMonster.<>c__DisplayClass1.<EatTheException>b__0() in c:\Projects\Visual Studio\Squiggle\Squiggle.Utilities\ExceptionMonster.cs:line 22
at Squiggle.Utilities.ExceptionMonster.EatTheException[T](Func1 action, String actionDescription, Boolean& success, Exception& ex) in c:\Projects\Visual Studio\Squiggle\Squiggle.Utilities\ExceptionMonster.cs:line 40
Erorr occured while logging history.: System.InvalidOperationException: The 'Id' property on 'Session' could not be set to a 'System.Guid' value. You must set this property to a non-null value of type 'System.String'.
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader
1.GetValue(DbDataReader reader, Int32 ordinal)
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String typeName)
at lambda_method(Closure , Shaper )
at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet)
at lambda_method(Closure , Shaper )
at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator
1.ReadNextElement(Shaper sh

comments

hasankhan wrote Dec 30, 2015 at 3:43 PM

Update the id column definition to default to newid()

scottd0866 wrote Dec 30, 2015 at 5:08 PM

Ok i'll try that.... I thought it might of been something simple like that....

just an FYI I found another solution that I think works as well. I reversed engineered your changelog changing GUID to String, and changed those values back to GUID and it began working again as well.

scottd0866 wrote Dec 31, 2015 at 4:31 PM

FYI adding newid() as the default value for column id in Events didn't work either. I believe the problem is the communication between LINQ and entityframework and how it reads GUID for the different databases. Changing those vars from strings to GUID does work however in the new model