private static AviaBuildDBEntities Connect(string userName, string password, out string connectionString) { AviaBuildDBEntities dbContext = null; connectionString = null; try { var entityString = new EntityConnectionStringBuilder() { Provider = "System.Data.SqlClient", Metadata = "res://*/AviaBuildDBModel.csdl|res://*/AviaBuildDBModel.ssdl|res://*/AviaBuildDBModel.msl", ProviderConnectionString = @"data source=PC-KMS\SQLEXPRESS;initial catalog=AviaBuildDB;integrated security=False;MultipleActiveResultSets=True;App=EntityFramework" }; entityString.ProviderConnectionString += ";user id=" + userName + ";Password=" + password; connectionString = entityString.ConnectionString; dbContext = new AviaBuildDBEntities(connectionString); if (dbContext.Database.Exists()) { return(dbContext); } } catch (Exception ex) { Console.WriteLine(ex); } dbContext?.Dispose(); return(null); }
public WindowProcedures(AviaBuildDBEntities context) { InitializeComponent(); Instance = this; this.context = context; }
public MainWindow(AviaBuildDBEntities context) { this.context = context; InitializeComponent(); }
private void RefreshAll() { context.Dispose(); context = new AviaBuildDBEntities(DataHandler.Instance.CurrConnectionString); }