【问题标题】:Cannot attach a file as database in child solution of partitioned solutions无法在分区解决方案的子解决方案中将文件附加为数据库
【发布时间】:2013-03-25 04:20:04
【问题描述】:

我最近开始使用MVC 4 开发分区解决方案,我使用Structuring Solutions and ProjectsAdding an existing Visual Studio solution to another solution 设置我的解决方案。我的系统已全部设置好,可以构建,并且我已在两种解决方案上启用了迁移。每个解决方案有 4 个项目(域、数据、单元测试和 WebUI),子解决方案有来自主解决方案的引用。数据层包含所有存储库和 DbContext 类。每个解决方案都有自己的连接字符串,因此我打算为添加到系统中的每个解决方案创建单独的数据库。

我试图使用Update Database -Verbose 更新Package Manager Console 中的数据库,这适用于主解决方案,但不适用于子解决方案。迁移文件位于数据层。

注意:我运行Update-Database -Verbose

Using StartUp project Master.WebUI and Using NuGet project Master.Data(主解决方案)

Using StartUp project Child.WebUI and Using NuGet project Child.Data(子解决方案)

我应该怎么做才能完成这项工作?

【问题讨论】:

  • 我并没有完全解决这个问题,但我所做的是重新创建 Child solution 并制作第一个 Updat-Database,然后将其添加到 Master Solution

标签: c# asp.net-mvc-4 visual-studio-2012 ef-code-first entity-framework-migrations


【解决方案1】:

起初我无法解决这个问题,所以我所做的是重新创建 Child solution 并在将其添加到 Master Solution 之前创建第一个 Updat-Database

现在,我认为只需检查以确保Database 不存在于其他任何地方。所以从App_DataServer ExplorerSQL Server Object Explorer 删除你的database 将在.mdf file cannot be attached as a database 的情况下起作用

【讨论】:

  • 我的问题是 App_Data 是空的,我仍然得到那个恼人的错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-12
  • 2016-03-18
  • 1970-01-01
  • 2021-05-06
  • 1970-01-01
相关资源
最近更新 更多