[{"data":1,"prerenderedAt":406},["ShallowReactive",2],{"blog:2009:linq-to-sql-changes-in-net-40":3,"blogMore-Development":392,"comments-linq-to-sql-changes-in-net-40":405},{"id":4,"title":5,"body":6,"category":373,"commentCount":374,"date":375,"description":12,"excerpt":376,"extension":377,"filenames":378,"hidden":379,"image":378,"meta":380,"minutes":381,"navigation":382,"path":383,"seo":384,"showCategory":378,"stem":385,"tags":386,"updated":378,"url":389,"wordCount":390,"__hash__":391},"content\u002Fblog\u002F2009\u002Flinq-to-sql-changes-in-net-40.md","LINQ to SQL changes in .NET 4.0",{"type":7,"value":8,"toc":353},"minimark",[9,13,23,28,33,54,58,97,101,160,164,189,193,207,211,219,223,244,248,290,294,327,331,334,338,341,345,348],[10,11,12],"p",{},"People have been asking via Twitter and the LINQ to SQL forums so here’s a list I put together on a number of the changes made for 4.0.",[14,15,16],"blockquote",{},[10,17,18,22],{},[19,20,21],"em",{},"25 Aug 2009",", updated with additional changes, some of which are new in beta 2.",[24,25,27],"h2",{"id":26},"change-list","Change list",[29,30,32],"h3",{"id":31},"performance","Performance",[34,35,36,40,47],"ul",{},[37,38,39],"li",{},"Query plans are reused more often by specifically defining text parameter lengths (when connecting to SQL 2005 or later)",[37,41,42,43],{},"Identity cache lookups for primary key with single result now includes ",[44,45,46],"code",{},"query.Where(predicate).Single\u002FSingleOrDefault\u002FFirst\u002FFirstOrDefault",[37,48,49,50,53],{},"Reduced query execution overhead when DataLoadOptions specified (cache lookup considers ",[44,51,52],{},"DataLoadOptions"," value equivalency)",[29,55,57],{"id":56},"usability","Usability",[34,59,60,66,80,83,86,92],{},[37,61,62,65],{},[44,63,64],{},"ITable\u003CT>"," interface for additional mocking possibilities",[37,67,68,71,72,75,76,79],{},[44,69,70],{},"Contains"," with enums automatically casts to ",[44,73,74],{},"int"," or ",[44,77,78],{},"string"," depending on column type",[37,81,82],{},"Associations can now specify non-primary-key columns on the other end of the association for updates",[37,84,85],{},"Support list initialization syntax for queries",[37,87,88,91],{},[44,89,90],{},"LinqDataSource"," now supports inherited entities",[37,93,94,96],{},[44,95,90],{}," support for ASP.NET query extenders added",[29,98,100],{"id":99},"query-stability","Query stability",[34,102,103,112,118,124,131,134,151,154,157],{},[37,104,105,107,108,111],{},[44,106,70],{}," now detects self-referencing ",[44,109,110],{},"IQueryable"," and doesn’t cause a stack overflow",[37,113,114,117],{},[44,115,116],{},"Skip(0)"," no longer prevents eager loading",[37,119,120,123],{},[44,121,122],{},"GetCommand"," operates within SQL Compact transactions",[37,125,126,127,130],{},"Exposing ",[44,128,129],{},"Link\u003CT>"," on a property\u002Ffield is detected and reported correctly",[37,132,133],{},"Compiled queries now correctly detect a change in mapping source and throw",[37,135,136,139,140,143,144,146,147,150],{},[44,137,138],{},"String.StartsWith",", ",[44,141,142],{},"EndsWith"," and ",[44,145,70],{}," now correctly handle ",[44,148,149],{},"~"," in the search string (regular & compiled queries)",[37,152,153],{},"Now detects multiple active result sets (MARS) better",[37,155,156],{},"Associations are properly created between entities when using eager loading with Table-Valued Functions (TVFs)",[37,158,159],{},"Queries that contain sub-queries with scalar projections now work better",[29,161,163],{"id":162},"update-stability","Update stability",[34,165,166,172,177,183,186],{},[37,167,168,171],{},[44,169,170],{},"SubmitChanges"," no longer silently consumes transaction rollback exceptions",[37,173,174,176],{},[44,175,170],{}," deals with timestamps in a change conflict scenario properly",[37,178,179,182],{},[44,180,181],{},"IsDbGenerated"," now honors renamed properties that don’t match underlying column name",[37,184,185],{},"Server-generated columns and SQL replication\u002Ftriggers now work instead of throwing SQL exception",[37,187,188],{},"Improved binding support with the MVC model binder",[29,190,192],{"id":191},"general-stability","General stability",[34,194,195,198,204],{},[37,196,197],{},"Binary types equate correctly after de-serialization",[37,199,200,203],{},[44,201,202],{},"EntitySet.ListChanged"," fired when adding items to an unloaded entity set",[37,205,206],{},"Dispose our connections upon context disposal (ones passed in are untouched)",[29,208,210],{"id":209},"database-control","Database control",[34,212,213],{},[37,214,215,218],{},[44,216,217],{},"DeleteDatabase"," no longer fails with case-sensitive database servers",[29,220,222],{"id":221},"sqlmetal","SQLMetal",[34,224,225,228,231,234,241],{},[37,226,227],{},"Foreign key property setter now checks all affected associations not just the first",[37,229,230],{},"Improved error handling when primary key type not supported",[37,232,233],{},"Now skips stored procedures containing table-valued parameters instead of aborting process",[37,235,236,237,240],{},"Can now be used against connections that use ",[44,238,239],{},"AttachDbFilename"," syntax",[37,242,243],{},"No longer crashes when unexpected data types are encountered",[29,245,247],{"id":246},"linq-to-sql-class-designer","LINQ to SQL class designer",[34,249,250,253,256,259,265,271,274,277,284,287],{},[37,251,252],{},"Now handles a single anonymously named column in SQL result set",[37,254,255],{},"Improved error message for associations to nullable unique columns",[37,257,258],{},"No longer fails when using clauses are added to the partial user class",[37,260,261,264],{},[44,262,263],{},"VarChar(1)"," now correctly maps to string and not char",[37,266,267,270],{},[44,268,269],{},"Decimal"," precision and scale are now emitted correctly in the DbType attributes for stored procedures & computed columns",[37,272,273],{},"Foreign key changes will be picked up when bringing tables back into the designer without a restart",[37,275,276],{},"Can edit the return value type of unidentified stored procedure types",[37,278,279,280,283],{},"Stored procedure generated classes do not localize the word ",[44,281,282],{},"Result"," in the class name",[37,285,286],{},"Opening a DBML file no longer causes it to be checked out of source control",[37,288,289],{},"Changing a FK for a table and re-dragging it to the designer surface will show new FK’s",[29,291,293],{"id":292},"code-generation-sql-metal-linq-to-sql-class-designer","Code generation (SQL Metal + LINQ to SQL class designer)",[34,295,296,299,302,305,315,318,321],{},[37,297,298],{},"Stored procedures using original values now compiles when the entity and context namespaces differ",[37,300,301],{},"Virtual internal now generates correct syntax",[37,303,304],{},"Mapping attributes are now fully qualified to prevent conflicts with user types",[37,306,307,310,311,314],{},[44,308,309],{},"KnownTypeAttributes"," are now emitted for ",[44,312,313],{},"DataContractSerializer"," with inheritance",[37,316,317],{},"Delay-loaded foreign keys now have the correct, compilable, code generated",[37,319,320],{},"Using stored procedures with concurrency no longer gets confused if entities in different namespace to context",[37,322,323,326],{},[44,324,325],{},"ForeignKeyReferenceAlreadyHasValueException"," is now thrown if any association is loaded not just the first",[24,328,330],{"id":329},"potentially-breaking-changes","Potentially breaking changes",[10,332,333],{},"We worked very hard to avoid breaking changes but of course any potential bug fix is a breaking change if your application was depending on the wrong behavior. The ones I specifically want to call out are:",[29,335,337],{"id":336},"skip0-is-no-longer-a-no-op","Skip(0) is no longer a no-op",[10,339,340],{},"The special-casing of 0 for Skip to be a no-op was causing some subtle issues such as eager loading to fail and we took the decision to stop special casing this. This means if you had syntax that was invalid for a Skip greater than 0 it will now also be invalid for skip with a 0. This makes more sense and means your app would break on the first page now instead of subtlety breaking on the second page. Fail fast :)",[29,342,344],{"id":343},"foreignkeyreferencealreadyhasvalue-exception","ForeignKeyReferenceAlreadyHasValue exception",[10,346,347],{},"If you are getting this exception where you weren’t previously it means you have an underlying foreign key with multiple associations based on it and you are trying to change the underlying foreign key even though we have associations loaded.Best thing to do here is to set the associations themselves and if you can’t do that make sure they aren’t loaded when you want to set the foreign key to avoid inconsistencies.",[10,349,350],{},[19,351,352],{},"[)amien",{"title":354,"searchDepth":355,"depth":355,"links":356},"",2,[357,369],{"id":26,"depth":355,"text":27,"children":358},[359,361,362,363,364,365,366,367,368],{"id":31,"depth":360,"text":32},3,{"id":56,"depth":360,"text":57},{"id":99,"depth":360,"text":100},{"id":162,"depth":360,"text":163},{"id":191,"depth":360,"text":192},{"id":209,"depth":360,"text":210},{"id":221,"depth":360,"text":222},{"id":246,"depth":360,"text":247},{"id":292,"depth":360,"text":293},{"id":329,"depth":355,"text":330,"children":370},[371,372],{"id":336,"depth":360,"text":337},{"id":343,"depth":360,"text":344},"Development",67,"2009-06-01T14:15:29+00:00","[object Object]","md",null,false,{},4,true,"\u002Fblog\u002F2009\u002Flinq-to-sql-changes-in-net-40",{"title":5,"description":12},"blog\u002F2009\u002Flinq-to-sql-changes-in-net-40",[387,388],".NET","LINQ","\u002Fblog\u002F2009\u002Flinq-to-sql-changes-in-net-40\u002F",815,"eBnq6S5Mp4Dndft0N5nt6MlgrIj4fw3j-2kEYClgZIM",[393,397,401],{"title":394,"date":395,"url":396},"Transactions in the MongoDB EF Core Provider","2025-10-25","\u002Fblog\u002F2025\u002Fmongodb-explicit-transactions\u002F",{"title":398,"date":399,"url":400},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","\u002Fblog\u002F2025\u002Fmongodb-queryable-encryption\u002F",{"title":402,"date":403,"url":404},"Lazy Loading with EF Core Proxies","2025-04-02","\u002Fblog\u002F2025\u002Fef-proxies\u002F",[],1780900527448]