实体框架4.1代码首先在数据库'master'中拒绝CREATE DATABASE权限 [英] entity framework 4.1 code first CREATE DATABASE permission denied in database 'master'

查看:152
本文介绍了实体框架4.1代码首先在数据库'master'中拒绝CREATE DATABASE权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Entity Framework 4.1创建了一个通用的存储库项目,它在我们的项目中作为一个现有的项目被添加到它们时很好,但是当它被直接引用为dll时它们不起作用。



我收到这个错误


数据库'master'中的CREATE DATABASE权限被拒绝。 >


但我添加了 app.config 文件并设置相关的连接字符串对我的SQL Server 2005数据库(我已经使用 DbContext 作为我的上下文)



请帮助我。 p>

这是我的连接字符串:

 < configuration> 
< connectionStrings>
< add name =TasksEntities
connectionString =server =(local); database = Tasks; trusted_connection = false; User = sa; Password = ****; Persist Security Info = True
providerName =System.Data.SqlClient/>
< / connectionStrings>
< / configuration>


解决方案

我刚刚遇到这个问题。连接字符串名称必须与DbContext子类的类名完全匹配。如果没有EF不会找到连接字符串,并且会尝试回退做其他(SQL嵌入式),这在我的机器上不起作用(我已经安装了完整的SQL Server)。


I have created a generic repository project using Entity Framework 4.1 and it works great with my projects when added as an existing project to them but it doesn't work on them when just referenced as dll.

I get this error

CREATE DATABASE permission denied in database 'master'.

but I have added app.config file and set relevant connection string to my SQL Server 2005 database (I have used DbContext as type my context)

Please help me.

Here is my connection string :

<configuration>
   <connectionStrings>
      <add name="TasksEntities" 
           connectionString="server=(local); database=Tasks; trusted_connection=false; User=sa; Password=****; Persist Security Info=True" 
           providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

解决方案

I just ran into this myself. The connection string name must match the class name of your DbContext subclass exactly. If it doesn't EF will not find the connection string and will try and fall back to doing something else (SQL embedded?) which doesn't work on my machine (I have full SQL Server installed).

这篇关于实体框架4.1代码首先在数据库'master'中拒绝CREATE DATABASE权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆