1
Я использую Entity framework 4.1, следующий метод, который я использую для вставки данных в таблицу, в которую он не вставляет данные в таблицу.Entity framework Context.SaveChanges() не вставляет данные в таблицу
Метод:
private void InsertSMSStatus(Request request)
{
UtilitiesEntities context = new UtilitiesEntities();
SMSAlertLog alertLog = new SMSAlertLog();
alertLog.Recipients = request.To;
alertLog.Sender = From;
alertLog.Status = Convert.ToInt32(request.ResponseString);
context.SaveChanges();
context.Dispose();
}
Строка соединения:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /></startup><connectionStrings><add name="UtilitiesEntities" connectionString="metadata=res://*/DataModel.SmsEntityModel.csdl|res://*/DataModel.SmsEntityModel.ssdl|res://*/DataModel.SmsEntityModel.msl;provider=System.Data.SqlClient;provider connection string="data source=bosql1srv;initial catalog=Utilities;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /></connectionStrings></configuration>
Любая идея?
Вы ничего не добавили в свой контекст. Вам нужно сделать что-то вроде этого: 'context.AlertLogs.Add (alertLog); context.SaveChanges(); '.. в зависимости от вашего контекста курса. –
oops that was misss .... Спасибо – ankur