I am using the ADO.NET Mocking Context Generator to generate my entity classes from an EDMX file, so that I can use them in unit tests. However, after I generate my entities and try to build the project, I get the following error:
The type name 'DateTime' does not exist in the type 'MyProject.Models.System'
Within the code, DateTime properties are declared in the format:
public virtual System.DateTime LastActive
If I change System.DateTime to just DateTime, the error clears. Unfortunately this is not practical, as there quite a lot of them, besides they will be overwritten next time I regenerate.
Why am i receiving this error, and how can I prevent it?
It looks like the problem is that you’ve got a type called
System. That’s a really bad idea – it’s going to cause this problem all over the place. (See Eric Lippert’s blog posts on this topic for more details…)The most specific way of declaring this would be:
If you could change the generator to create that, it should be okay… but personally I’d just change the
Systemtype to be called something else if you possibly can.