简体   繁体   English

实体框架 - ConnectionString 上的底层提供程序失败

[英]Entity Framework - The underlying provider failed on ConnectionString

While using the Entity Framework I have split it out to it's own project:在使用实体框架时,我已将其拆分为自己的项目:

  • RivWorks.Model - Contains Entity Model RivWorks.Model - 包含实体模型
  • RivWorks.Controller - Uses the Entity Model and contains the biz rules RivWorks.Controller - 使用实体模型并包含商业规则
  • RivWorks.View.Web - The web site RivWorks.View.Web - 网站
  • RivWorks.View.Services - WCF project RivWorks.View.Services - WCF 项目

Everything in the web site is working fine.网站上的一切都运行良好。 I am able to call into the Controller and get a valid Model back.我能够调用控制器并获得一个有效的模型。 When I try the same thing from the Web.Service I am getting this error:当我从 Web.Service 尝试同样的事情时,我收到此错误:

ERROR:错误:
The underlying provider failed on ConnectionString. ConnectionString 上的基础提供程序失败。
STACK TRACE:堆栈跟踪:
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)在 System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)在 System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)在 System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)在 System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at RivWorks.Model.Entities.RivFeedsEntities1..ctor(String connectionString)在 RivWorks.Model.Entities.RivFeedsEntities1..ctor(String connectionString)
at RivWorks.Model.FeedStoreReadOnly..ctor(String connectionString)在 RivWorks.Model.FeedStoreReadOnly..ctor(String connectionString)
at RivWorks.Controller.ProductManager.LookupProduct(String productID, String sku, String urlRef, String env, String logPath)在 RivWorks.Controller.ProductManager.LookupProduct(String productID, String sku, String urlRef, String env, String logPath)

I am a bit confused as to why and digging through the error logs I finally figured out the connection strings were not being read from the Web Site's config file.我对为什么和挖掘错误日志感到有些困惑,我终于发现没有从网站的配置文件中读取连接字符串。 So, I added some code to catch that and, for now, hard coded the values in. Like:所以,我添加了一些代码来捕捉它,现在,硬编码了这些值。比如:

public dataObjects.NegotiateSetup LookupProduct(string productID, string sku, string urlRef, string env, string logPath)
{
    string feedConnString = "";
    string rivConnString = "";

    log.InitializeLogFile(logPath);
    dataObjects.NegotiateSetup resultSet = new dataObjects.NegotiateSetup();

    try { feedConnString = AppSettings.FeedAutosEntities_connString; }
    catch { feedConnString = @"metadata=res://*/Entities.FeedEntities.csdl|res://*/Entities.FeedEntities.ssdl|res://*/Entities.FeedEntities.msl;provider=System.Data.SqlClient;provider connection string='Data Source=***.***.***.***;Initial Catalog=******;Persist Security Info=True;User ID=******;Password="******";MultipleActiveResultSets=True'"; }

    try { rivConnString = AppSettings.RivWorkEntities_connString; }
    catch { rivConnString = @"metadata=res://*/Entities.RivEntities.csdl|res://*/Entities.RivEntities.ssdl|res://*/Entities.RivEntities.msl;provider=System.Data.SqlClient;provider connection string='Data Source=******;Initial Catalog=******_Dev;Persist Security Info=True;User ID=******;Password="******";MultipleActiveResultSets=True'"; }

    try
    {
        using (RivFeedsEntities1 _dbFeed = new FeedStoreReadOnly(feedConnString).ReadOnlyEntities())
        {
            using (RivEntities _dbRiv = new RivWorksStore(rivConnString).NegotiationEntities())
            {

But, alas, it is still giving me the above error!但是,唉,它仍然给我上述错误! Any ideas why?任何想法为什么?

I know you've been mucking around with your connection strings to sanitize them but I'm guessing you didn't put the "我知道你一直在摆弄周围与你的连接字符串来净化他们,但我猜你没有把" 's around the password in?周围的密码在?

Are they actually required?难道他们实际需要?

Double check your connection string is correct, little typo's can cause this same error.仔细检查您的连接字符串是正确的,小错字的可能会导致同样的错误。

This is wrong:这是错误的:

 <add name="Entities" connectionString="metadata=res://*/OnlineAB.csdl|res://*/OnlineAB.ssdl|res://*/OnlineABSuperAdmin.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source.;initial catalog=

This is right:这是对的:

 <add name="Entities" connectionString="metadata=res://*/OnlineAB.csdl|res://*/OnlineAB.ssdl|res://*/OnlineABSuperAdmin.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=

See after the DataSource I was missing an equal sign.请参阅我的DataSource缺少等号后面。

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

相关问题 基础提供程序连接字符串失败 - Underlying provider failed in connectionstring 基础提供程序在ConnectionString上失败 - The underlying provider failed on ConnectionString 实体框架异常“底层提供程序打开失败” - Entity Framework Exception “The underlying provider failed on Open” 基础提供程序在实体框架中打开时失败 - The underlying provider failed on Open in entity framework connection 基础提供程序无法打开-WPF和实体框架 - The underlying provider failed to open - WPF and Entity FrameWork 实体框架底层提供程序在打开时失败 - Entity Framework The underlying provider failed on Open 基础提供程序在ConnectionString PostgreSql EF6上失败 - The underlying provider failed on ConnectionString PostgreSql EF6 具有SQLite异常的实体框架:底层提供程序在Commit上失败 - Entity Framework with SQLite exception: The underlying provider failed on Commit NServiceBus和实体框架导致异常-基础提供程序在打开时失败 - NServiceBus and Entity Framework causes exception - The underlying provider failed on Open 在实体框架上下文中使用单例模式-基础提供程序在打开时失败 - Using singleton pattern with Entity Framework context - The underlying provider failed on open
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM