Mixing EntityFramework ForEachAsync with using keyword

יום רביעי, מרץ 26, 2014

I just encountered an interesting question on Microsoft Web Developer forum What is the problem with below code? static void Main(string args) { RunAsyncEF(); Console.ReadKey(); } static void RunAsyncEF() { using (MyContext context = new MyContext()) { context.Products.ForEachAsync(p => { Console.WriteLine(p.Name); }); } } Surprisingly nothing is written to the Console window and no error is reported at run time My...
no comments

Implementing Composite Pattern with Entity Framework Code First – Part 2

יום חמישי, מרץ 17, 2011

In my previous blog post I described the way you can implement Composite pattern using Entity Framework Code First. The sample uses EFCodeFirst CTP 5 which suffers from a minor bug related to the composite relationship. Microsoft just released EF 4.1 RC which fixes the issue. Now, you can implement your composite pattern in a clean fashion. You can find the fixed composite pattern sample here.