Ok so here's some context: I'm using EF5, MVC4 and SQL CE4 to build up a web application. I've been loosely following this tutorial with a few differences.
- My context class and POCO objects are in their own assembly.
- I'm using SQL CE4 instead of SQL Express Local DB
- My classes aren't as simple as the tutorial
I've already used a workaround to get simple classes to work register.
I had thought using enums in EF5 was supported in EF5, but can they be used in Keys?
When I try to add a control (Add Controller, MVC controller with read/write actions and views, using Entity Framework) for a simple class (1 int key property, 1 string property), it works. I get varied errors when trying to add a class that has a property which is part of a key (primary or foreign)
Unable to retrieve metadata for 'blah'. Using the
same DbCompiledModel to create contexts against different types of
database servers is not supported. Instead, create a separate
DbCompiledModel for each type of server being used.
Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index
C:\Program Files (x86)\Microsoft Visual Studio\11.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\
CodeTemplates\AddController\ControllerWithContext.tt(0,0) : error :
Running transformation: System.IndexOutOfRangeException: Index was outside the bounds of the
array.
---StackTrace---
The only similarities I've found between these classes is that they have an emun that's tied to a key. Other classes with non-key enums generate correctly. Is this the issue or have I completely missed the mark?
Edit: Example of a class which fails
public class A
{
public virtual AIdEnum Id { get; set; }
public virtual string Name { get; set; }
public virtual ICollection<B> Bs { get; set; }
public virtual ICollection<C> Cs { get; set; }
}