✅ Not able to Insert data to table using Dapper
Hey folks! I'm trying to have Dapper insert a MapsModel to the database with a relation to the PlayerModel. However, when I try to do that, I get this error:
The code I use can be found in this pastebin:
https://pastebin.com/q99mmvnX
Anyone know how I can solve this?
Pastebin
[Table("Maps")]public class DbMap{ [Key] public long Id { get...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
4 Replies
Dapper is a very light ORM
It just does some basic mappings
It won't insert nested data, like that
DbPlayer
nested inside of DbMap
You'd need to insert the player first, get the generated ID, then insert the map
Or write SQL that does both manually
Or... use EF that will be able to insert nested data no problemAlright, great to know. We're using Dapper because its quite a bit faster than EF, just have to get used to it. Thanks alot for the response!
Eh, it's not that much faster
In face, EF Core is on par with a lot of the time
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Closed!