所以我已经生成了我需要的表,并且我需要能够在我的程序启动时更改我的连接字符串。目前我的连接是
"metadata=res://*/entityframework.Model1.csdl|res://*/entityframework.Model1.ssdl
|res://*/entityframework.Model1.msl;provider=MySql.Data.MySqlClient;
provider connection string="server=localhost;User Id=myuserid;
password=12345678;database=databasename""
到目前为止我所拥有的
获取.designer.cs 文件:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.EntityClient;
using Npgsql;
using System.Configuration;
using System.Data.Entity;
using System.Data.Entity.Validation;
using patientlist.entityframework;
using System.Xml;
namespace patientlist
{
public partial class Get : Form
{
Timer update = new Timer();//60000 = 1min
public Get()
{
InitializeComponent();
} ....
private void Timer(object sender, EventArgs e)
{
string connectionString = "metadata=res://*/entityframework.Model1.csdl|res://*/entityframework.Model1.ssdl|res://*/entityframework.Model1.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;User Id=myuserid;password=12345678;database=databasename"";
using (var blah = new ltcsystemEntities())
{
blah.Database.Connection.ConnectionString = connectionString;
} .....
我正在使用 EF5,它首先是 DB(我从我的实体模型生成了一些自动化代码)