webform采用的是普通开发+sqlite+ADO.Net 实体模型(EF)上传到网站后出现如下错误,请问如何解决
问题描述
Server Error in '/' Application.
--------------------------------------------------------------------------------Keyword not supported: 'data source'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Keyword not supported: 'data source'.Source File: e:\webroot\kendeji\web\Index.aspx    Line: 9 
Line 7:  
Line 8:  <%
Line 9:      ProConfigInfoData pcid = new ProConfigInfoData();
Line 10:     ConfigInfoModel cim = pcid.QueryConfig();
Line 11:     if (cim == null)
 
Stack Trace: 
[ArgumentException: Keyword not supported: 'data source'.]
   System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +5110868
   System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +98
   System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +118
   System.Data.EntityClient.EntityConnection..ctor(String connectionString) +81
   System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) +42
   System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +16
   Dragon.F3._5.WebForm.DB.DragonWFSqliteEntities..ctor(String connectionString) +42
   Dragon.F3._5.WebForm.backstage.ConfigInfo.ProConfigInfoData..ctor() +50
   ASP.index_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in e:\webroot\kendeji\web\Index.aspx:9
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060
看堆栈信息好像是链接字符串出了问题,ado.net实体在本地创建的时候指定了绝对路径,上传到服务器后已经修改了路径,单还是会报错。出错的页面Index.aspx,我在这个页面new 了一个类,那个类在new 了一个实体模型。
 

解决方案 »

  1.   

    是的,看看连接字符串data source写错没
      

  2.   

    我本地测试是可以的,现在我重新生成一个EF实体后,出现如下问题。Server Error in '/' Application.
    --------------------------------------------------------------------------------Unable to find the requested .Net Framework Data Provider.  It may not be installed. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.Source Error: 
    Line 7:  
    Line 8:  <%
    Line 9:      ProConfigInfoData pcid = new ProConfigInfoData();
    Line 10:     ConfigInfoModel cim = pcid.QueryConfig();
    Line 11:     if (cim == null)
     Source File: e:\webroot\kendeji\web\Index.aspx    Line: 9 Stack Trace: 
    [ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.]
       System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1420519
       System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +35[ArgumentException: The specified store provider cannot be found in the configuration, or is not valid.]
       System.Data.EntityClient.EntityConnection.GetFactory(String providerString) +62
       System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +263
       System.Data.EntityClient.EntityConnection..ctor(String connectionString) +81
       System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString) +42
       System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +16
       Dragon.F3._5.WebForm.DB.DragonWFSqliteEntities..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\DB\DragonWFSqlite.Designer.cs:26
       Dragon.F3._5.WebForm.backstage.ConfigInfo.ProConfigInfoData..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\backstage\ConfigInfo\ProConfigInfoData.cs:14
       ASP.index_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in e:\webroot\kendeji\web\Index.aspx:9
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       System.Web.UI.Page.Render(HtmlTextWriter writer) +29
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060 
      

  3.   

    本来是用sqlite轻量级的数据库加EF的Linq语句,开发起来很方便,本地测试都好好的,但是一传到服务器问题就一个接着一个。哎……,实在不行,只能用access重新做了。
    有没有朋友用sqlite+EF开发过?有碰到我这样的问题吗?
      

  4.   

    好像看出了一点猫腻。
    源错误在服务器上:Source File: e:\webroot\kendeji\web\Index.aspx    Line: 9 
    而堆栈的错误在
      Dragon.F3._5.WebForm.DB.DragonWFSqliteEntities..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\DB\DragonWFSqlite.Designer.cs:26
       Dragon.F3._5.WebForm.backstage.ConfigInfo.ProConfigInfoData..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\backstage\ConfigInfo\ProConfigInfoData.cs:14

    类怎么会跑绝对路径去获取数据呢?
      

  5.   

    看看你服务器上面的net版本~~~~
      

  6.   

    我通过查看堆栈
    源错误在服务器上:Source File: e:\webroot\kendeji\web\Index.aspx Line: 9 
    而堆栈的错误在
    Dragon.F3._5.WebForm.DB.DragonWFSqliteEntities..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\DB\DragonWFSqlite.Designer.cs:26
    Dragon.F3._5.WebForm.backstage.ConfigInfo.ProConfigInfoData..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\backstage\ConfigInfo\ProConfigInfoData.cs:14
    我都是编译后再上传的?怎么类里面会有我本地的路径?这个是我在本地写得一个类
    Dragon.F3._5.WebForm.backstage.ConfigInfo.ProConfigInfoData..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\backstage\ConfigInfo\ProConfigInfoData.cs:14
    这个实体数据是在本地创建的创建的时候让选择路径,选了以后通过查看属性,路径是本地的,但是我通过在web.config中配置的是服务器的,为什么错误出现后会看到本地的地址?
    Dragon.F3._5.WebForm.DB.DragonWFSqliteEntities..ctor() in D:\项目\MVC项目\Dragon.F3.5.WebForm\Dragon.F3.5.WebForm\DB\DragonWFSqlite.Designer.cs:26
      

  7.   

    string providerName = "System.Data.SqlClient";
                    string serverName = serverAddr;
                    string databaseName = "TTTTT";                SqlConnectionStringBuilder sqlBuilder =
                        new SqlConnectionStringBuilder();                sqlBuilder.DataSource = serverName;
                    sqlBuilder.InitialCatalog = databaseName;
                    sqlBuilder.IntegratedSecurity = false;
                    sqlBuilder.UserID = userId;
                    sqlBuilder.Password = password;
                    sqlBuilder.MultipleActiveResultSets = true;                string providerString = sqlBuilder.ToString();                EntityConnectionStringBuilder entityBuilder =
                        new EntityConnectionStringBuilder();                //Set the provider name.
                    entityBuilder.Provider = providerName;                // Set the provider-specific connection string.                entityBuilder.ProviderConnectionString = providerString;                entityBuilder.Provider = providerName;                // Set the Metadata location.
                    entityBuilder.Metadata = @"res://*/CRM.ZHaoCRM.csdl|
                                               res://*/CRM.ZHaoCRM.ssdl|
                                               res://*/CRM.ZHaoCRM.msl";
                    //或从.config文件中copy
                    //@"res://*/NBModel.csdl|
                    //res://*/NBModel.ssdl|
                    //res://*/NBModel.msl";
                    string str = entityBuilder.ToString();
                    return str;
      

  8.   

    照着这上面改吧
    ~~~调用      sharedCtx = new Model.SharedEntities(Connections.SharedConnectionString);      
      

  9.   

    这样就不依赖于webconfig中的配置了
      

  10.   


    如果自己通过程序写链接字符串,有没有什么需要设置的?例如删除web.config中的链接字符串后,那怎么样调用自己写得链接字符串呢?根据这个重载来实例化?
    /// <summary>
            /// 初始化新的 DragonWFSqliteEntities 对象。
            /// </summary>
            public DragonWFSqliteEntities(string connectionString) : 
                    base(connectionString, "DragonWFSqliteEntities")
            {
                this.OnContextCreated();
            }
      

  11.   

    是的,将上面的所有代码封装为一个静态方法,返回一个string ~~~
    实例化时传入该string~~需要注意的是metadata要从相关的config中拷贝进来~
      

  12.   

    后来还是换了sql2005的数据库。问题解决了。