实体框架无法实例化dbcontext

时间:2015-10-08 22:57:12

标签: jquery sql-server entity-framework asp.net-web-api entity-framework-6

这段代码编译得很好但我的jquery ajax返回

错误:

  

无法加载资源:服务器响应状态为500(内部服务器错误)
  app.js:37 jqXHR = [object Object] textStatus = error errorThrown =内部服务器错误

上下文:

 public class IssuesServiceContext : DbContext
 {
    public IssuesServiceContext() : base("name=IssuesServiceContext")
    {
        this.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
    }

    public DbSet<IssuesModel> IssuesModels { get; set; }
}

web.config

<connectionStrings>
    <add name="IssuesServiceContext" 
         connectionString="Data Source=SQLDEV\ESG;Initial Catalog=ABC;User ID=abc;Password=password" 
         providerName="System.Data.SqlClient"/>
</connectionStrings>

似乎在这一行失败

public IssuesServiceContext() : base("name=IssuesServiceContext")

1 个答案:

答案 0 :(得分:0)

我想通了,我也在项目中使用了Oracle。我确实想使用Oracle的实体框架,并决定不这样做。

在Web.config中,我不得不删除此行

<provider invariantName="Oracle.ManagedDataAccess.Client" type="Oracle.ManagedDataAccess.EntityFramework.EFOracleProviderServices, Oracle.ManagedDataAccess.EntityFramework, Version=6.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />