Reputation: 855
I have a table in a SQL database with some columns Entdate
which is "not nullable" is one of them with type of date
.
I have set the default binding of that column with getdate()
function. Now in my project I am using Entity Framework (database first) with mvc 4. So I got a property called Entdate
in my model (which is generated by Entity Framework, because I am using database first approach). I don't want to pass any value to this (EntDate
, because in the database I have used getdate()
function as default constraint for the Entdate
column) property, I just need to fetch the data from Entdate
column from SQL database. How can I do this?
If I remove the set property of the Entdate
property in model, it generates an error, I can't pass null value to it because Entdate
is not nullable in database. What should I do? Any suggestion will be appreciated. Thanks in advance :)
Upvotes: 1
Views: 1517
Reputation: 109080
Set its StoreGeneratedPattern
= Computed
and its Setter
= private
as in this example:
Upvotes: 3