Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework Mapping SQL Server tinyint to Int16

My Entity Data Model is giving me this error:

Error 2019: Member Mapping specified is not valid. The type 'Edm.Int16[Nullable=True,DefaultValue=]' of ... is not compatible with 'SqlServer.tinyint[Nullable=True,DefaultValue=]' of ...

I've tried deleting and recreating the property. I don't know what I've done wrong.

like image 666
Zack Peterson Avatar asked May 02 '11 22:05

Zack Peterson


People also ask

Should I use Tinyint?

If you include 2 or 3, you have to use tinyint (at the very smallest scale). "For example, it's better to use tinyint when you know that the only data you will store is a 1, 0 or null (with a very small chance of expanding that to a 2 or 3 later)." I'd use an ENUM for such a thing.

What is the use of Tinyint in SQL?

The TINYINT data type is an integer value from 0 to 255. TINYINT is the smallest integer data type and only uses 1 byte of storage. An example usage of TINYINT is a person's age since no person reaches the age of 255.

What is Int16 SQL?

Int16 struct. It is signed and takes 16 bits. It has minimum -32768 and maximum +32767 capacity.


1 Answers

A tinyint should get mapped to a .NET byte; Int16 should be the corresponding type for a smallint in SQL.

like image 166
Joel C Avatar answered Sep 28 '22 01:09

Joel C