Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Core will not map to BigInteger

I am needing to use the BigInteger class to handle large integers to my classes, however when trying to use EntityFramework Core to map to a DB table I recieve the following error:

The property AllianceRank.Reputation could not be mapped, because it is of type BigInteger which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it.

[Column("reputation")]
public BigInteger Reputation { get; set; }

It would seem that BigIntegers are not a supported type for mapping. How can I force it to map, or otherwise resolve this issue?

like image 902
Douglas Gaskell Avatar asked Jan 25 '17 04:01

Douglas Gaskell


1 Answers

Entity Framework would have to make assumptions about how to store that. If you're using SQL server, for example, bigint doesn't work because your values could be larger or smaller than what's possible with bigint. Would varchar be more appropriate? Possibly, but if you truly mean it to be a number and not say, an identifier, asking EF to query that as a number is going to be problematic. So essentially, there are less ambiguous types like long or string where you're not leaving the guesswork on how to store it up to Entity Framework.

like image 94
Chad Hedgcock Avatar answered Sep 30 '22 04:09

Chad Hedgcock