【问题标题】:Error in Entity framework code first实体框架代码首先出错
【发布时间】:2015-09-26 09:11:10
【问题描述】:

不知道为什么我会收到此错误。这是一个练习代码,所以我学习了实体框架代码第一方法。

我在 web.config 中有以下内容

<add name="CompanyDBContext"
     connectionString="server=.; database=CompanyDB;integrated security=true;"
     providerName="System.Data.SqlClient"/>
<connectionStrings>

和下面的类

public class CompanyDBContext: DbContext
{

    public  DbSet<Department> Departments { get; set; }
    public DbSet<Employee> Employees { get; set; }

}

错误是:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

提前致谢!

【问题讨论】:

    标签: entity-framework-5 code-first


    【解决方案1】:

    连接字符串格式错误。正确的是:

    <connectionStrings>
        <add name="CompanyDBContext"
             connectionString="server=.; database=CompanyDB;integrated security=true;"
             providerName="System.Data.SqlClient"/>
    </connectionStrings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      • 2011-08-29
      • 2011-11-07
      • 1970-01-01
      相关资源
      最近更新 更多