实体框架在Visual Studio中失去对连接字符串的绑定 [英] Entity Framework losing binding to connection string in Visual Studio

查看:151
本文介绍了实体框架在Visual Studio中失去对连接字符串的绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,其中Entity Framework的edmx文件显然失去了与它构建的连接字符串的关系。



我的设计师。 edmx文件工作正常 - 我可以做从数据库更新,它总是跳转到向导步骤,这将允许我添加表,procs等。现在当我点击从数据库更新,我得到选择你的数据连接向导步骤,它要我选择一个新的数据库 - 如果我通过这些步骤,它将为我创建一个新的连接字符串,并重新生成所有的对象,就像我从头开始。 >

我的app.config文件的内容与问题完全一样,但是我修改了该文件,然后将其还原。我想以某种方式修改此文件会触发某些导致我失去绑定的东西,但我无法确定是什么。



连接字符串键在配置文件与EDMX文件中的CdmEntityContainer属性匹配。



我甚至尝试杀死我的代码库并从源代码控制中重新检出,但似乎不上班。在同一代码库上工作的其他人也遇到同样的问题,所以在项目中似乎有一些肯定是错误的。但是.csproj或.sln文件没有相关的更改 - 只要我可以看到任何可能导致这种情况的内容。



任何想法?我现在看到的唯一解决方案是从头删除并重新创建edmx文件,但我绝对希望找到更好的东西。



编辑:如果我在项目中生成一个全新的edmx,与任何现有的edmx无关,似乎修复了其余的。它必须重置项目中任何时髦的东西。但是这不是一个合法的解决方案,所以我仍然希望能够做得更好。

解决方案

在我的连接字符串中我缺少



应用程序名称=数据源中的EntityFramework数据源


I'm having a problem where the Entity Framework edmx file is apparently losing its relationship to the connection string that it was built with.

The designer for my .edmx file was working perfectly - I could do "Update from database" and it would always jump to the wizard step that would allow me to add tables, procs, etc. Now when I click "Update from database", I get the "Choose your data connection" wizard step where it wants me to select a new database - if I go through these steps, it will create a new connection string for me, and regenerate all of the objects as if I was starting from scratch.

The contents of my app.config file are exactly as they were prior to the problem, but I did modify the file, then revert it back the way it was. I'm thinking somehow modifying this file triggers something that causes me to lose the binding, but I can't figure out what that is.

The connection string key in the config file matches the CdmEntityContainer attribute in the EDMX file.

I've even tried killing my codebase and re-checking-out from source control, but that doesn't seem to work. Other people working on the same codebase are having this same problem, so it seems that there's something definitely wrong somewhere in the project. But there were no relevant changes to the .csproj or .sln files - just nothing I can see anywhere that could be causing this.

Any ideas? The only solution I'm seeing right now is to delete and recreate the edmx files from scratch, but I'm definitely hoping to find something better.

EDIT: If I generate a brand new edmx in the project, unrelated to any of the existing ones, it seems to fix the rest. It must "reset" whatever is funky in the project. But this can't be a legitimate solution, so I'm still hoping for something better.

解决方案

I just had this issue and in my connection string I was missing

application name=EntityFramework in the data Source

这篇关于实体框架在Visual Studio中失去对连接字符串的绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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