Reputation: 345
I have an app that uses a Web API to connect to a server. One of the columns, IsActive
, is set to a default value of true or 1. The column defined as a bit
datatype.
When I make an entry into the table using SQL Server, IsActive
is set to 1. If I make the entry using Postman or the app, the value of IsActive
is set to 0.
My questions are:
Upvotes: 0
Views: 256
Reputation: 188
Looks like what @Dai commented answers your first question that it's likely a limitation of entity framework in your WebApi that is causing the issue.
To answer your second question.
If you have a model with the property public bool IsActive
, that you want to default to true
then you will need to make sure you assign IsActive = true
before saving the record. Otherwise your API is passing false
by default to the database.
Upvotes: 2