简体   繁体   English

实体框架未在app.config中使用连接字符串

[英]Entity Framework not using connection string in app.config

My error message states 我的错误讯息状态

The underlying provider failed on Open 基础提供程序在打开时失败

and the InnerException states that the database cannot open by the requested login. 并且InnerException指出无法通过请求的登录名打开数据库。

The strange thing is that my connectionString is showing a different login than what's mentioned in the error. 奇怪的是,我的connectionString显示的登录名不同于错误中提到的登录名。 Why is the application using an incorrect connectionString than the one that's explicitly defined in my App.Config? 为什么应用程序使用的连接字符串比我的App.Config中明确定义的连接字符串错误?

Few common reasons why: 几个常见原因为何:

1) You aren't using that project as your StartUp Project 1)您没有将该项目用作启动项目

2) You didn't match the name in the config 2)您与配置中的名称不匹配

<connectionStrings>
    <add name="YourContext"... >
</connectionStrings>

3) You are hard coding it in the YourContext.cs 3)您正在YourContext.cs进行硬编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 App.Config中的实体框架连接字符串 - Entity Framework Connection String in App.Config 在Entity Framework的app.config中更改连接字符串 - Changing connection string in app.config for Entity Framework 在app.config中找不到实体框架连接字符串 - Can't Find Entity Framework Connection String in app.config app.config和用于远程连接的实体框架 - app.config and Entity Framework for remote connection 实体框架(代码优先到现有数据库)-在运行时覆盖app.config中的连接字符串 - Entity Framework(Code First to an existing database) - overwrite a connection string in app.config at runtime 强制实体框架和ASP.MVC使用另一个程序集的app.config中的连接字符串 - Forcing Entity Framework and ASP.MVC to use the connection string from app.config of another assembly 实体框架迁移无法在App.config文件中找到连接字符串 - Entity Framework Migration cant find connection string in App.config file 实体框架抛出无效操作异常 - 找不到app.config中的连接字符串 - Entity framework throwing invalid operation exception - Connection string in app.config not found App.Config 连接字符串 - App.Config Connection String app.config中的连接字符串 - Connection string in app.config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM