You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So here I sit and switch from EF to Dapper because CodeFirst with several thousands of AddOrUpdate in Seed was getting a bit irritating when debugging thanks to our beloved Change Tracking... usual story of people switching to Dapper...
... and then I encountered this:
publicclassWhoInTarnationThoughtThatDozensOfTablesWithOneColumnIsGoodIdea{[Key][Dapper.Contrib.Extensions.ExplicitKey]//dapper fails to detect his as Key automatically :([DatabaseGenerated(DatabaseGeneratedOption.None)][StringLength(250)]publicstringSomethingNotNamedIdToMakeMyDayWorse{get;set;}}
So first issue was "Entity must have at least one [Key] or [ExplicitKey] property ", but there are already tickets for it and can be solved with that silly ExplicitKey attribute. No biggie. Build, start, make a tea while this overweight abomination of a project starts up and munches through hundred migrations... oh different exception.
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'where'...
(You won't get exception if you have non-key fields in table. Single-column table is a must.)
So there are 3 problems (aside of database design I got stuck with...):
Key column detection sucks, but thats because Dapper isn't checking EF attributes and can be fixed with ExplicitKey attribute.
Invalid SQL when there is no "non-id properties" as SET clause ends up empty. Would be nice to have explicit exception here instead of raw error.
Due to offending line [IsWriteable(true)] is not working on Key columns like [DatabaseGenerated(DatabaseGeneratedOption.None)] does in EF, because all Key columns are excluded from list of updateable fields.
So I'd like to ask, before wasting half an hour to fix it, IsWriteable vs ExplicitKey a feature or a bug?
The text was updated successfully, but these errors were encountered:
So here I sit and switch from EF to Dapper because CodeFirst with several thousands of AddOrUpdate in Seed was getting a bit irritating when debugging thanks to our beloved Change Tracking... usual story of people switching to Dapper...
... and then I encountered this:
So first issue was "Entity must have at least one [Key] or [ExplicitKey] property ", but there are already tickets for it and can be solved with that silly ExplicitKey attribute. No biggie. Build, start, make a tea while this overweight abomination of a project starts up and munches through hundred migrations... oh different exception.
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'where'...
Here's the culprit:
Dapper.Contrib/src/Dapper.Contrib/SqlMapperExtensions.cs
Line 438 in cf24f6b
(You won't get exception if you have non-key fields in table. Single-column table is a must.)
So there are 3 problems (aside of database design I got stuck with...):
[IsWriteable(true)]
is not working on Key columns like[DatabaseGenerated(DatabaseGeneratedOption.None)]
does in EF, because all Key columns are excluded from list of updateable fields.So I'd like to ask, before wasting half an hour to fix it, IsWriteable vs ExplicitKey a feature or a bug?
The text was updated successfully, but these errors were encountered: