I have a strange issue where I started getting an error trying to insert into a table.
Cannot insert the value NULL into column 'Id', table 'OptionSettlementValues'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Here is the code for that object
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }
public string UnderlyingSymbol { get; set; }
public DateTime Expiration { get; set; }
public decimal SettlementPriceUnderlying { get; set; }
public string Type { get; set; }
public OptionSettlementValue()
{}
public OptionSettlementValue(string underlyingSymbol, string expiration, string settlementPriceUnderlying, string type)
{
UnderlyingSymbol = underlyingSymbol;
Expiration = DateTime.Parse(expiration);
SettlementPriceUnderlying = decimal.Parse(settlementPriceUnderlying);
Type = type;
}
Here is my code to insert:
var db = new Context("JTradeAdmin");
db.OptionSettlementValue.Add(new OptionSettlementValue("OEX", "1/4/2013", "664.69", "weekly"));
db.SaveChanges();