丢失了与数据库的连接 [英] Lost connection to the database

查看:69
本文介绍了丢失了与数据库的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!

我正在使用Visual Studio 2015.

I am using Visual Studio 2015.

1)我在C#中创建了一个小程序来更改一个数据在数据库中(使用控制台)

1) I created a small program in C# to change one data in a database ( using console )

2)首先,我使用add->创建了数据库。新项目>数据库工具。

2) First I created the database by using the add-> new item > database tool.

3)然后我添加了一个实体框架(ADO.NET实体数据模型

3) then I added an Entity Framework (ADO.NET Entity Data Model

4)然后在 中编写了以下代码static void(.......)此代码来自另一个用户,其中RecipesEntities是

4) then wrote the following code in  the static void(.......) This code is from another user where RecipesEntities is the

实体框架,Table是Recipes数据库表中的表。

Entity framework, Table is the Table in Tables of the Recipes database.

RecipesEntities context = new RecipesEntities();

           

               表recip =新表()

                {

                    Name =" Chicken Salad"&
                }; b $ b                context.Tables.Add(recip);

                context.SaveChanges();

RecipesEntities context = new RecipesEntities();
           
                Table recip = new Table()
                {
                    Name = "Chicken Salad"
                };
                context.Tables.Add(recip);
                context.SaveChanges();

5)在启动应用程序之前,我使用服务器资源管理器检查数据库,连接正常。(绿色)

5)Before Starting the application I check the database using the Server Explorer and the connection is OK.(green)

6)当我启动应用程序时,与数据库的连接丢失(变为红色)并且什么都不能改变,

6) When I start the application the connection with the database is lost (turn red) and nothing can be change,

7)我尝试过其他情况(网页和桌面应用程序,总是一样的情况!

7)I tried with other situations( Web Page and desk application, always the same situation!

8)我能做些什么来使数据库连接正常工作?

8) What can I do to get the database connection working?

谢谢你?

推荐答案

Hi MiGa52,

Hi MiGa52,

根据您的描述,您似乎首先是实体框架数据库。请参考以下文档开始。

According to your description, it seems that you entity framework database first. please refer to the following document to get started.

https://msdn.microsoft.com/en-us/data/jj206878(v = vs.113).aspx

祝你好运,

Cole Wu


这篇关于丢失了与数据库的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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