Entity Framework

10 posts

The peculiar problem when your entity framework query returns the same row for every record

This one had me confused for a long time, several hours in fact.  There were over 8,000 rows in the table, and the for some reason the query was returning the same row 8,000 times.  After much rending of garments and gnashing of teeth, I discovered that the table in question (in a sql server […]

Connecting Entity Framework to Sql Server 2000

A lesson learned – when trying to map Entity Framework to Sql Server 2000  (if you must) – make sure that there are no nullable dates – if so, work around them.  I just spent hours looking into that.

Linq projection with the extension method syntax

I’ve looked this up an embarrassing number of times – here is how you do linq projection with the extension method syntax List<TypeClassification> typeClassifications = ctx.Classes.Select(e => new TypeClassification() {Name = e.Name, TypeClassificationID = e.ClassificationID}).ToList(); Hopefully I shall remember.  I’m not sure why I can’t remember the exact syntax.

Five things should should know about the new asp.net identity membership system

I’m trying my first asp.net mvc 5 project, which more or less forces you to use the new asp.net identity framework for membership. It’s in the using Microsoft.AspNet.Identity namespace. While a vast improvement over the original asp.net membership – I do not see any massive benefit over the MVC 4 Simple Membership system.  Here are […]

How to fix the “error 2025: XML Schema validation failed for mapping schema.” error

The Problem You’ve been upgrading and downgrading Entity Framework, and just when everything seems to be working, you get an error of Schema specified is not valid. Errors: <File Unknown>(0,0) : error 2025: XML Schema validation failed for mapping schema. Schema Error Information : The ‘https://schemas.microsoft.com/ado/2012/10/edm/migrations:IsSystem’ attribute is not declared.. <File Unknown>(0,0) : error 2025: […]

How to fix problems with entity framework decimal precision

The Problem You are attempting to change a database column of type decimal from a precision of two decimal place to one decimal place via data annotations, and there does not seem to be a good way to do it. The Cause There isn’t a good way to do it. The Solution However, there is […]

How to fix problems with ReSharper LINQ Intellisense

The Problem Resharper’s Intellisense, while generally awesome, does not find navigation properties in Linq statements The Cause: No Idea The Solution Switch back to Visual Studio 2012’s Intellisense, then go to Resharper > Options > Environment > General and make sure that the “Store Caches in the System Temp Folder Close and Reopen Visual Studio […]

How to programatically set the sql server database used by entity framework

The Problem: For one reason or another you need to set the database used by entity framework programatically.  The more common way of doing such a thing is to set the database in your web.config class, but for whatever reason you need to set it in actual C# code. The Cause: There is no cause […]

How to fix yet another You must set this property to a non-null value of type ‘Double’ problem with Entity Framework

The Problem You are coding happily away in Visual Studio 2010, working on your asp.net project, using the entity framework and sql server and you get and you get the following error The ‘Amount’ property on ‘SomeTable’ could not be set to a ‘Decimal’ value. You must set this property to a non-null value of […]

How to Fix Missing records in Linq to Entities

The Problem You are attempting to use Linq to Entities in the standard way, your linq model does not seem to have any records attached.  You have missing records in Linq to Entities. You look in the database, and the proper record is there.  You do a context.MyEntry.Count().ToString() and it tells you there is one […]