实体框架6:找不到服务器或无法访问服务器 [英] Entity Framework 6: The server was not found or was not accessible

查看:92
本文介绍了实体框架6:找不到服务器或无法访问服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 [本教程] ,试图在C#控制台应用程序中创建EF数据库,但是(即使我完全按照教程中的说明进行操作)它也会失败

I'm following [this tutorial], I'm trying to create EF database in C# console application, but (even if I do exactly everything as in tutorial) it fails on

db.Blogs.Add(blog);
db.SaveChanges();

行。错误:


在EntityFramework.dll中发生了类型为 System.Data.SqlClient.SqlException的未处理异常。附加信息:建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确,并且已将SQL Server配置为允许远程连接。 (提供者:SQL网络接口,错误:52-无法找到本地数据库运行时安装。验证是否正确安装了SQL Server Express,并且启用了本地数据库运行时功能。)

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll. Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)

正如教程的作者所说,它不应该要求我做任何事情来配置数据库,但看起来确实如此。

As author of tutorial says, it shouldn't require me to do anything to configure my DB, but it seems like it does.

我应该怎么做才能使其正常工作?

我使用的软件:
Visual Studio 2015,EntityFramework 6.1 .3。

Software that I use: Visual Studio 2015, EntityFramework 6.1.3.

推荐答案

对我有用的解决方案是:

The solution that worked for me is:


  1. 打开Visual Studio安装程序(用于安装Visual Studio的* .exe文件)

  2. 单击修改按钮

  3. 找到 Microsoft SQL Server数据工具并进行检查

  4. 单击更新

  1. Open Visual Studio installer (*.exe file used to install Visual Studio)
  2. Click on "Modify" button
  3. Find "Microsoft SQL Server Data Tools" and check it
  4. Click "Update"

现在您的数据库应该可以使用了。

Now your database should work.

这篇关于实体框架6:找不到服务器或无法访问服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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