2

我正在使用Entity framework 4.1,我使用以下方法在表中插入数据它不是在表中插入数据。

方法:

    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=&quot;data source=bosql1srv;initial catalog=Utilities;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings></configuration>

任何想法?

4

1 回答 1

6

您没有将实体添加到上下文中。

context.SMSAlertLogs.Add(alertLog); // name of entity set may change. It might not be SMSAlertLogs 
context.SaveChanges();
于 2013-06-03T12:15:25.413 回答