我收到错误“底层提供程序在打开时失败。” 实际上我没有调用实体框架连接字符串我的代码是,
InspectionEntities dbContext = new InspectionEntities();
当“InspectionEntities”为时如何传递实体框架连接字符串,
namespace DataAccessManager
{
public class InspectionEntities : ObjectContext
{
public InspectionEntities();
public InspectionEntities(EntityConnection connection);
public InspectionEntities(string connectionString);
和检查是,
[assembly: EdmSchemaAttribute()]
namespace DataAccessManager
{
#region Contexts
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public partial class InspectionEntities : ObjectContext
{
#region Constructors
/// <summary>
/// Initializes a new InspectionEntities object using the connection string found in the 'InspectionEntities' section of the application configuration file.
/// </summary>
public InspectionEntities() : base("name=InspectionEntities", "InspectionEntities")
{
OnContextCreated();
}
/// <summary>
/// Initialize a new InspectionEntities object.
/// </summary>
public InspectionEntities(string connectionString) : base(connectionString, "InspectionEntities")
{
OnContextCreated();
}
/// <summary>
/// Initialize a new InspectionEntities object.
/// </summary>
public InspectionEntities(EntityConnection connection) : base(connection, "InspectionEntities")
{
OnContextCreated();
}
#endregion
我的连接字符串是
<add name="InspectionEntities" connectionString="metadata=res://*/Inspection.csdl|res://*/Inspection.ssdl|res://*/Inspection.msl;provider=System.Data.SqlClient;provider connection string="Data Source=*****\SQLEXPRESS;Initial Catalog=Inspection;User ID=sa;Password=****;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
InspectionEntities dbContext = new InspectionEntities();
当我使用它的对象 dbcontext 获取数据时,它给了我错误,因为基础提供程序在打开时失败
如何在这里传递或调用实体连接字符串,
InspectionEntities dbContext = new InspectionEntities("name=InspectionEntities");
???
我在这里也一样
希望你的建议
提前致谢