【发布时间】:2017-09-14 08:21:44
【问题描述】:
我正在尝试部署我的 ASP.NET MVC5 网站以按照本教程进行测试: https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-to-iis
在关于“为应用程序数据库配置部署”第 2 点的部分中,我需要选中一个在我的屏幕上不可用的框(执行代码优先迁移)。我的问题如下:我有一个洋葱架构,因此我的项目包含实体框架的上下文是在一个单独的项目中(我正在部署 asp.net MVC 5 项目),这意味着我不能enable-migrations in这个项目。我还更改了我的连接字符串以适合我在这篇文章中精确描述的上下文名称:https://stackoverflow.com/a/32866872/4714502。另一方面,我的 DbSet 与我的实体框架类有不同的名称,这会是一个问题吗?我这样做是因为我的表的语法很尴尬,而且是一个要求(我不想在我的应用程序中使用这个命名约定)。说一个表 Web_Documents :
DbSet<Web_Documents> WebDoc { get; set; }
至于我的架构:
- 实体 (POCO)
- 存储库(上下文在这里)
- 服务
- UI (MVC)(在此处部署)
依赖关系从 4 变为 1。
这是我在 Repository 中的 app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<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>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="PrincipalServerContext" connectionString="Data Source=SMRFG12APP13\SQLEXPRESS;Initial Catalog=PrincipalServerDB;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
我的数据库名称是 PrincipalServerDB 和上下文 PrincipalServerContext
现在我没有想法了,真的不知道我还能做什么?
【问题讨论】:
标签: c# asp.net-mvc entity-framework visual-studio-2017 webdeploy