używam Entity Framework 5 kodowej pierwszy approch. Oto mój plik Kontekst:Jak dodać "Nazwa dostawcy" w ciągu połączenia do pliku kontekstowego?
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";
}
}
}
tutaj Dodałem ciąg połączenia w konstruktorze. Ale czy istnieje jakiś sposób dodania "nazwy dostawcy" do ciągu połączenia?
Twój ciąg połączenia wygląda jak "Ciąg połączenia SQLClient", więc dostawcą jest 'SQLClient', dodajemy' Nazwę dostawcy' tylko w łańcuchu połączenia OleDB'. –