4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Entity Frameworkでコードファーストをする時の注意点

Posted at

Entity Framework4.1からの新機能、コードファーストは非常に素晴らしいのです。
しかし昨日から何故かテストが通らずに
System.InvalidOperationException: The model backing the 'xxxContext' context has changed since the database was created
という例外が出てハマりまくってました。

解決策は簡単で、Web.configのconnectionStringsのaddタグのname属性を、
コンテキストクラス名の「xxxContext」の__Contextを抜いた「xxx」の部分__と同じにしないといけない制約があるそうです。

name属性を「xxxContext」にしていて丸一日ハマってました・・・。

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?