본문 바로가기

DB/Entity Framework

(12)
[EntityFramework]Unable to update the EntitySet because it has a DefiningQuery and no <UpdateFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. Unable to update the EntitySet {{TABLE_NAME}} because it has a DefiningQuery and no element exists in the element to support the current operation.해당 Entity 에 primary key 가 있는지 확인 합니다. (대부분 pk가 없어서 발생하는 오류임.)
[EntityFramework] Support Spatial Data for stored procedure on SqlServer 2008R2 edmx designer 로 sp 를 add 하면 spatial data type ( geometry/geography ) 의 class 가 edmx 에 생성되지 않습니다. solution #1 Install service pack / feature pack - https://goo.gl/q2xUTf solution #2 To add scalar property in *.tt class - https://goo.gl/xZJA42 2번 추천합니다.
[c#][Linq][Entityframework] ContextSwitchDeadlock occurred ContextSwitchDeadlock occurredMessage: Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe'.Additional information: CLR에서 60초 동안 COM 컨텍스트 0xd58440에서 COM 컨텍스트 0xd584f8(으)로 전환하지 못했습니다. 대상 컨텍스트/아파트를 소유하는 스레드가 펌프 대기를 수행하지 않거나, Windows 메시지를 펌프..
[c#][Linq][EntityFramework] 메모리 누수 방지를 위한 Skip, Take 사용방법 int totalCount = 0;int amountToSkip = 0;int processAmount = 0;Boolean finished = false; using(var context = new {{DataContext}}()){ totalCount = context.{{테이블}}.Where({{조건절}}).Count(); while (!finished) { resultList = context.{{테이블}} .Where({{조건절}}) .OrderBy({{정렬조건}}) //Skip, Take 사용을 위해 정렬 필수 .Skip(amountToSkip) .Take(1000).ToList(); //Take 수는 적절히 조정 processAmount = resultList.Count; if (result..
[Z.EntityFramework.extention][bulkinsert] c# example using (var context = new KSKEntities()) { context.Configuration.AutoDetectChangesEnabled = false; context.Configuration.ValidateOnSaveEnabled = false; context.Database.Connection.Open(); using (var ts = new TransactionScope()) { try { context.BulkInsert(SampleList); context.BulkSaveChanges(); ts.Complete(); Console.WriteLine("bulk insert : OK"); } catch (Exception ex) { ts.Dispose(); Console.Wri..
[Z.EntityFramework.extention][BulkInsert] 열 ID %1에 대해 bcp 클라이언트에서 잘못된 열 길이를 받았습니다. 열 ID %1에 대해 bcp 클라이언트에서 잘못된 열 길이를 받았습니다. bulkinsert 에 필요한 데이터 구문이 잘려서 이후 데이터가 들어가지 않고 예외를 발생합니다. 해결책 1. garbage collector C# 의 경우에는 GC.Collect() 로 garbage collector 를 실행해주면 어느정도 해결이 됩니다. 확실한 해결책은 아니란 얘기~. garbage collector 의 실행부분은 반복문 하단이나 단위 메소드의 실행 끝에 실행해줍니다. 적절히 garbage 가 clear 되었는지는 visual studio > analyze > performance and Diagnostics 에서 모니터링 할 수 있는데 Force GC 로 강제로 실행 할 수 있는 버튼도 지원해서 임의로 cl..
[Visual Studio][Entity Framework 6] How to delete auto-generated Comments ooo.edmx > ooo.Context.tt line 21 ~ 28 //------------------------------------------------------------------------------ // // // // // // //------------------------------------------------------------------------------ ooo.edmx > ooo.tt line 228 ~ 235 //------------------------------------------------------------------------------ // // // // // // //---------------------------------------------..
error CS1061: 'int' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?) error CS1061: 'int' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?) 1. 원인 entoty framework 에 매핑 한 stored procedure 가 model 을 제대로 생성 할 수 없을때 발생하는 오류입니다.1-1. 예sp 내부에 #TEMP 테이블 join이나 select 가 있으며 list 로 가져올 컬럼을 매핑 할 수 없을 때 발생합니다. 즉, var onbidObjectList =..