连接SQL Express实体框架 [英] Connecting SQL Express Entity Framework

查看:85
本文介绍了连接SQL Express实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试设置一个实体框架应用程序,但是我遇到了一些困难。 App.config中的连接信息如下所示。



So I am trying to setup an Entity framework app, however I am having some difficulty. The connection information in the App.config looks like.

<connectionStrings>
    <add name="CVEContext" providerName="System.Data.SqlClient" connectionString="data source=.\SQLEXPRESS;Initial Catalog=cvedb; user=cvepoc; Password='#'; Integrated Security=SSPI"/>
  </connectionStrings>





我的DbContext上课看起来像。





My DbContext class looks like.

public class CVEContext : DbContext
   {
       public DbSet<CveEntity> CveEntities { get; set; }



       public CVEContext()
           : base("name=CVEContext")
           {
               Database.SetInitializer<CVEContext>(new CreateDatabaseIfNotExists<CVEContext>());
           }


   }





有趣的是,这里是连接信息不应该工作。密码错误,但是,我一直收到一条错误消息,指出在主人中创建数据库密码被拒绝



建议?



The interesting thing, here is the connection information should not work. The password is wrong, however, I consistently get an error message stating that "Create Database password denied in master"

Suggestions?

推荐答案

CdnSecurityEngineer写道:
CdnSecurityEngineer wrote:



综合安全= SSPI


Integrated Security=SSPI



该设置告诉连接忽略指定的用户名和密码,并使用Windows身份验证进行连接。密码错误并不重要,因为它从未使用过。

http:// www .connectionstrings.com / sql-server / [ ^ ]



错误消息告诉您数据库 cvedb 不存在,以及您的Windows帐户没有权限创建它。尝试运行提升的应用程序,这应该为您提供必要的权限。


That setting tells the connection to ignore the username and password specified, and connect using Windows authentication. It doesn't matter that the password is wrong, because it's never used.
http://www.connectionstrings.com/sql-server/[^]

The error message is telling you that the database cvedb doesn't exist, and your Windows account doesn't have permission to create it. Try running the application elevated, which should give you the necessary permissions.


这篇关于连接SQL Express实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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