【发布时间】:2015-12-10 18:11:57
【问题描述】:
我启用了迁移 - 但是,现在我正在移动到实时服务器,似乎迁移仍在尝试更新数据库,因为我收到了错误:
CREATE TABLE permission denied in database 'secn'.
我的模型文件夹中的上下文文件中有这个:
namespace lhts2.Models
{
public class DefaultConnection : DbContext
{
public DefaultConnection() : base("name=DefaultConnection")
{
Database.SetInitializer<DefaultConnection>(null);
}
}
}
...在我的 web.config 文件中,我的连接字符串是:
<add name="DefaultConnection" connectionString="Data Source=[servername];
Initial Catalog=secn; Integrated Security=True;" providerName="System.Data.SqlClient" />
我也删除了 Migrations 文件夹并重新发布 - 但我仍然收到上述错误。
我的 web.config 文件中也有这个:
<configuration>
<configSections>
<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>
除了我的模型文件夹中的上下文文件之外,我是否需要在其他地方设置 SetInitializer?
感谢您的建议,
标记
【问题讨论】:
-
web.config 文件中有 EF 初始化吗?
-
嗨,布兰登 - 我想是的 - 我已经用 web.config 中提到的 EF 部分更新了我的问题 - 谢谢,
-
您有其他东西,例如可能正在尝试创建表格的会员服务提供商?
-
不——这是我从 VS2013 开始的一个干净的项目——我确实添加了实体框架,并为本地数据库做了一个更新数据库——除此之外,我没有添加任何其他包或提供者。
标签: asp.net-mvc entity-framework asp.net-mvc-3 asp.net-mvc-4