© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3mo ago•
7 replies
hutonahill

✅ EFCore type conversion.

https://gist.github.com/hutonahill/96ef2bea79847f5059ee13456833b0cc

I am working on a libray that runs a game. I've got a type
Card
Card
. it stores a card. I want EFCore to know how to store a card. so i wrote
CardToStringConverter
CardToStringConverter
(see the gist)

I want EFCore to use this whenever it sees Card.

I am writing a method that will add this converter (and any other i build) to properties that store a Card (other the other types i convert),
AddConverters
AddConverters
(see the gist)


The issue is collections. If i am storing a List<Card> this method wont work. Chat suggests this is not possible, but it can be kind of stupid for use cases like this, so i thought i would ask some real people with real experience.

i suspect i will have to create a
CardStorage
CardStorage
class that just stores a the string as an identifier, but i am trying to avoid that.
Gist
Converter Code
Converter Code. GitHub Gist: instantly share code, notes, and snippets.
Converter Code
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ User-defined implicit type conversion + type pattern match
C#CC# / help
3y ago
Convert enclosing type - implicit enum conversion
C#CC# / help
2y ago
SQL EFCore
C#CC# / help
2y ago
❔ efcore querying
C#CC# / help
3y ago