2013-06-03 1 views
1

테이블에 데이터를 삽입하지 않는 데이터를 삽입 할 때 다음 방법을 사용하는 Entity Framework 4.1을 사용하고 있습니다.엔티티 프레임 워크 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=&quot;data source=bosql1srv;initial catalog=Utilities;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings></configuration> 

어떤 생각?

+2

컨텍스트에 아무 것도 삽입하지 않았습니다. 이런 식으로해야합니다 :'context.AlertLogs.Add (alertLog); context.SaveChanges();'.. 당신의 컨텍스트에 따라 다릅니다. –

+0

그게 실수 였어 .... 고마워. – ankur

답변

5

컨텍스트에 엔티티를 추가하지 않습니다.

context.SMSAlertLogs.Add(alertLog); // name of entity set may change. It might not be SMSAlertLogs 
context.SaveChanges(); 
관련 문제