ASP.NET MVC 发布到虚拟空间碰到了问题!在数据库 'master' 中拒绝了 CREATE DATABASE 权限。

「已注销」 2015-07-13 12:15:10
在数据库 'master' 中拒绝了 CREATE DATABASE 权限。
怎么破?
求教!
我知道虚拟空间肯定不能创建 数据库的,肯定是用已有的,我想问 下怎么才能用EF连接已有的数据库而不让其自行创建数据库谢谢!


...全文
269 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2015-07-13
  • 打赏
  • 举报
回复
引用 1 楼 findcaiyzh 的回复:
你在web.config中指定连接字符串(指向已经存在的数据库),code first就不会新建数据库了。 参考 http://weblogs.asp.net/scottgu/using-ef-code-first-with-an-existing-database Importantly, though, the auto-create database option is just an option – it is definitely not required. If you point your connection-string at an existing database then EF “code first” will not try and create one automatically. The auto-recreate option also won’t be enabled unless you explicitly want EF to do this – so you don’t need to worry about it dropping and recreating your database unless you’ve explicitly indicated you want it to do so. For this blog post we will not auto-create the database. Instead, we’ll point at the existing Northwind database we already have. To do this we’ll add a “Northwind” connection-string to our web.config file like so:

connectionStrings>
      
    <add name="Northwind" 
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\northwind.mdf;User Instance=true" 
         providerName="System.Data.SqlClient" />
 
  </connectionStrings>
注意 链接字符串的name要匹配 你初始化DBContext时的名字,例如下面代码中的name=那个部分。

public class MyApplicationContext: DbContext
{
    public MyApplicationContext() : base("name=ConnectionStringName") { }

    public DbSet<Customer> Customers { get; set; }
}
好的,谢谢 ,我回去试试
Justin-Liu 2015-07-13
  • 打赏
  • 举报
回复
不用code first 连接现有数据库
  • 打赏
  • 举报
回复
现在的数据库连接字符串都不指定数据库的?
宝_爸 2015-07-13
  • 打赏
  • 举报
回复
你在web.config中指定连接字符串(指向已经存在的数据库),code first就不会新建数据库了。 参考 http://weblogs.asp.net/scottgu/using-ef-code-first-with-an-existing-database Importantly, though, the auto-create database option is just an option – it is definitely not required. If you point your connection-string at an existing database then EF “code first” will not try and create one automatically. The auto-recreate option also won’t be enabled unless you explicitly want EF to do this – so you don’t need to worry about it dropping and recreating your database unless you’ve explicitly indicated you want it to do so. For this blog post we will not auto-create the database. Instead, we’ll point at the existing Northwind database we already have. To do this we’ll add a “Northwind” connection-string to our web.config file like so:

connectionStrings>
      
    <add name="Northwind" 
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\northwind.mdf;User Instance=true" 
         providerName="System.Data.SqlClient" />
 
  </connectionStrings>
注意 链接字符串的name要匹配 你初始化DBContext时的名字,例如下面代码中的name=那个部分。

public class MyApplicationContext: DbContext
{
    public MyApplicationContext() : base("name=ConnectionStringName") { }

    public DbSet<Customer> Customers { get; set; }
}
源码链接: https://pan.quark.cn/s/8ddf8a1c92f9 **libcurl用于获取大型文件**libcurl作为一个开源的C语言库,提供了一系列的API来处理与URL相关的任务,涵盖了HTTP、FTP、SMTP等多种网络协议的应用。在执行大型文件的下载操作时,libcurl展现出卓越的性能表现和高度的灵活性,能够高效地管理大文件传输过程,有效预防内存溢出及其他潜在问题。**libcurl的基础操作**libcurl的基础应用包括以下几个环节:1. **初始化**:需要借助`curl_global_init()`函数来启动libcurl的工作环境。2. **建立会话句柄**:通过`curl_easy_init()`函数创建一个会话句柄,该句柄将用于后续所有的操作流程。3. **配置选项**:运用`curl_easy_setopt()`函数来设定多种参数,例如目标URL、超时时间、重试次数以及数据写入的回调函数等。4. **执行请求**:调用`curl_easy_perform()`函数来实施下载操作。5. **释放资源**:使用`curl_easy_cleanup()`函数来释放已经占用的资源。**获取大型文件时的重要设置**1. **数据写入回调函数**:在处理大型文件下载时,通常不希望一次性将整个文件载入内存。可以配置`CURLOPT_WRITEFUNCTION`选项,指定一个回调函数来处理接收到的数据片段,这样libcurl在接收到数据时会调用该函数,使得我们可以按需将数据写入文件或缓冲区。2. **缓冲策略**:可以设定缓冲区的大小(比如,通过`CURLOPT_BUFFERSIZE`),来控制每次接收数据的数量,从而优化内存...
内容概要:本文档整合了《鬼谷子·决篇》与《三略·审权变第三》《差德行第四》三大古代智慧典籍,构建了一套“决策+形势+用人”三位一体的领导力提升体系。通过28天三合实战路径、三维诊断工具、9个实用模板及独特的“身体锚点”仪式,系统解决管理者在决策犹豫、形势误判、人岗错配等方面的痛点。全文涵盖理论溯源、方法论拆解(如三步决策法、审权变四步法、差德行四步法)、历史案例对照(范蠡 vs 项羽)以及跨资源联动建议,形成从认知到实践的完整闭环。; 适合人群:基层管理者、创业者、职场进阶者,尤其是面临决策困境、环境适应困难或团队用人问题的人群;具备一定管理经验或自我提升意识的个体亦可受益。; 使用场景及目标:① 提升重大事项的决策质量,避免反复纠结与事后后悔;② 增强对外部环境变化的敏感度与应对能力,实现灵活调整;③ 科学评估人才德才素质,实现人岗精准匹配,减少用人失误;④ 构建个人化的决策-应变-用人标准化流程(SOP)。; 阅读建议:建议按照28天路径逐步实践,结合自测表定位短板,优先突破薄弱模块;配套工具模板需实际填写使用,配合身体锚点仪式强化行为记忆;可与“诸葛亮决策术”“立将威信术”等单品联动,全面提升领导力体系。

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧