我正在使用 Entity Framework 5 代码优先方法。这是我的上下文文件:
using IMS.Domain.Inventory;
using IMS.Domain.Security;
using IMS.Domain.StoredProcedures;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IMS.Domain.DBContext
{
public class IMSDBContext : DbContext
{
public DbSet<ModuleAccounting> ModuleAccountings { get; set; }
public DbSet<ModuleInfo> ModuleInfos { get; set; }
public DbSet<ModuleType> ModuleTypes { get; set; }
public DbSet<UserAccounting> UserAccountings { get; set; }
public DbSet<UserGroup> UserGroups { get; set; }
public DbSet<UserInfo> UserInfos { get; set; }
//
// set a connection string
public IMSDBContext() // Constructor of the Context
{
this.Database.Connection.ConnectionString =
"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=IMSDB;Data Source=.\\SQLExpress";
}
}
}
在这里,我在构造函数中添加了连接字符串。但是有没有办法将“提供者名称”添加到连接字符串中?