Common causes of DbContext has been disposed

On several occasions over the last couple of years I've seen the following exception being thrown in web applications that use Entity Framework. Once you know what might cause this issue it becomes quite obvious and easy to fix but for a junior developer or someone who hasn't experienced it…

Data Annotations for EF Generated Classes

Generating classes using entity framework is fairly problem free most of the time but you’ll soon find limitations once you need to add anything extra to these classes. EF generated classes are by default created as partial classes. This gives you the flexibility to create another ‘part’ to the…

Entity Framework Is Rounding My Decimals

So the last few hours I’ve been racking my brain trying to figure out at what point I was doing an INT conversion. After stepping through the code from the web tier down to the EF context no luck! I have a stored procedure in SQL Server 2014 that…