我写了一个相当简单的代码(基于 WCF 和 Windows 窗体的客户端服务器)。我试图更新数据库,以便我可以测试我的代码,但我遇到了上述异常。任何想法如何解决它?
// For testing
public void updateTable()
{
using (var db = new overlayDBEntities())
{
var overlaydb = new overlayData
{
DeviceId = "1111",
TimestampUTC = new DateTime(1990, 1, 1, 9, 9, 9),
OverlayData1 = "Random Text"
};
db.overlayData.Add(overlaydb);
try
{
db.SaveChanges();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
var overlaydb1 = new overlayData
{
DeviceId = "1111",
TimestampUTC = new DateTime(2000, 2, 2, 10, 10, 10),
OverlayData1 = "seconed seconed seconed "
};
db.overlayData.Add(overlaydb);
try
{
db.SaveChanges();
}
catch (Exception ec)
{
Console.WriteLine(ec.Message);
}
}
}