遅れないことを願っています。私はASP.NET MVC
4を使用Entity Framework 6 alpha 3
していますが、同様の問題が発生しました。
ソリューションに複数のプロジェクトがあります。2つの主なプロジェクトは次のとおりです。
MyProject.Infrastructure.EntityFramework
MyProject.Web
最初のプロジェクトでは、すべてのリポジトリなどを設定しましたDbContext
。このプロジェクトでは、2つの参照があります。
EntityFramework
EntityFramework.SqlServer
2番目のプロジェクトは私のウェブサイトです。最初のプロジェクトのリポジトリを使用してデータを返します。例えば:
private readonly IMyRepository myRepository;
public MyController(IMyRepository myRepository)
{
this.myRepository = myRepository;
}
public ActionResult Details(int id)
{
MyObject myObject = myRepository.FindById(id);
return View();
}
これは私が問題を抱えていた場所ですFindById
。
私がしたことは、私のWebサイトに次の参照を追加することだけでした。
EntityFramework.SqlServer
私のweb.configで:
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
そして、終了system.webServer
タグの下:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
これがお役に立てば幸いです。