I have a table which looks like:
[dbo].[Person](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](150) NULL,
[SysDate] [datetime] NOT NULL CONSTRAINT [DF_Person_SysDate] DEFAULT (getdate())
In my Wcf service
I'm using entity framework
but it doesn't work properly i.e. it is not saving the data model when the table has default field value.
Working solution which is not acceptable:
public void InsertPerson(Person model)
{
using (DbEntities db = new DbEntities())
{
db.AddToPerson(new Person() { Name = model.Name, SysDate = DateTime.Now });
db.SaveChanges();
}
}
Non working solution - solution which I'm tring to achieve:
public void InsertPerson(Person model)
{
using (DbEntities db = new DbEntities())
{
db.AddToPerson(model);
db.SaveChanges();
}
}