さて、ここにいくつかのコンテキストがあります。私はEF5、MVC4、およびSQLCE4を使用してWebアプリケーションを構築しています。私はこのチュートリアルを大まかにフォローしていますが、いくつかの違いがあります。
- 私のコンテキストクラスとPOCOオブジェクトは独自のアセンブリにあります。
- SQLExpressローカルDBの代わりにSQLCE4を使用しています
- 私のクラスはチュートリアルほど単純ではありません
私はすでに回避策を使用して、単純なクラスを機能登録させています。
EF5で列挙型を使用することはEF5でサポートされていると思っていましたが、キーで使用できますか?
単純なクラス(1つのintキープロパティ、1つの文字列プロパティ)のコントロール(Add Controller、読み取り/書き込みアクションとビューを備えたMVCコントローラー、Entity Frameworkを使用)を追加しようとすると、機能します。キーの一部であるプロパティ(プライマリまたは外部)を持つクラスを追加しようとすると、さまざまなエラーが発生します
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---
これらのクラス間で私が見つけた唯一の類似点は、キーに関連付けられたエムンがあることです。非キー列挙型を持つ他のクラスは正しく生成されます。これは問題ですか、それとも私は完全にマークを逃しましたか?
編集:失敗するクラスの例
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; }
}