0

我有一个引用另一个项目的测试项目,该项目又引用包含我的实体框架 5.0 文件 (edmx) 的第三个项目。我发现我可以直接从 Visual Studio 运行数据库驱动的单元测试,但是当我从 mstest 运行时,我收到以下错误:

System.Data.Entity.Infrastructure.UnintentionalCodeFirstException:如果在 Code First 模式下使用,使用 T4 模板生成的用于 Database First 和 Model First 开发的代码可能无法正常工作。要继续使用 Database First 或 Model First,请确保在执行应用程序的配置文件中指定了实体框架连接字符串。

我有运行良好的非数据库连接单元测试。我摆弄了我的各种 app.config EF 连接字符串,它们似乎没问题(每个测试在 Visual Studio 上运行良好)。问题是当我从桌面或构建服务器上的命令行运行 mstest 时。这是我使用的命令:

MSTest.exe /nologo /searchpathroot:"\Binaries" /resultsfileroot:"\TestResults" /testcontainer:"\Binaries\driver.orderedtest" /testcontainer:"\Binaries\EF.DataAccess.dll" /publish:"http:// /" /publishbuild:"vstfs:///Build/Build/99" /teamproject:"ProjectName" /platform:"Any CPU" /flavor:"Debug" /noisolation /detail:errormessage /detail:errorstacktrace /detail:stderr

我引用了测试项目中的所有 dll,如下所述:Entity Framework custom tool does not correct embed or load the model as resource files

我已经断断续续地做了几天,在我看来这是一个 EF 5.0 错误,但根据连接链接,这应该是固定的,但似乎并非如此。

4

0 回答 0