数据库'master'中的EF Code First CREATE DATABASE权限被拒绝 [英] EF Code First CREATE DATABASE permission denied in database 'master'

查看:133
本文介绍了数据库'master'中的EF Code First CREATE DATABASE权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先使用代码来创建和更新数据库.我在程序包管理器中的update-database命令一直工作到昨天.但今天它不起作用,并出现以下错误: CREATE DATABASE权限在数据库"master"中被拒绝. 我对连接字符串和其他配置没有任何更改. 因此,我尝试将数据库更新到系统和Windows上的另一个项目,并且可以毫无问题地重新创建和更新该数据库. 您可以帮我解决此错误吗?

I used code first for create and update database. My update-database commands in package manager worked until yesterday. But today it is not working and has this error: CREATE DATABASE permission denied in database 'master'. I do not any changes on connection string and other config. So I try to Update-database to another project on my system and my windows and I can recreate and update this database without any problem. Can you help me for fix this error?

这是我的有问题的项目的连接字符串:

This is my connection string for project that has problem:

<add name="Default" connectionString="Server=.\sqlexpress; Database=test1; User Id=sa; Password=123456" providerName="System.Data.SqlClient" />

这是我没有问题的项目的连接字符串:

this is my connection string for project that have not problem:

<add name="Default" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=test2;user id=sa;password=123456" providerName="System.Data.SqlClient" />

推荐答案

我找到了解决方案.

我在解决方案中有4个项目.但是当我尝试更新数据库时,Web项目未设置为启动项目.所以我将该项目设置为启动项目,然后可以更新数据库.

I have 4 project in the solution. but when I try to update-database, the web project does not set as start up project. so I set this project to start up project and I can update-database.

这篇关于数据库'master'中的EF Code First CREATE DATABASE权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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