EF+MySql
1安装MySQL Connector/Net
http://dev.mysql.com/downloads/connector/net/
2还需要下载一个MySQL for VisualStudio版本,用于在VS中可以在数据源中引用MySQL
http://dev.mysql.com/downloads/windows/visualstudio/
【添加环境变量:C:\wamp\bin\mysql\mysql5.6.17\bin,才能正常使用MySql控制台,不用控制台可以忽略此步骤】
3通过NuGet添加MySql引用
MySql.Data
MySql.Data.Entity
MySql.Data.Entity.EF6
4
[DbConfigurationType(typeof(MySqlEFConfiguration))]//添加特性 public partial class Model1 : DbContext { public Model1() : base("name=Model1") { } public DbSet<text123> text123 { get; set; } }
5
public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //注册MySql DbConfiguration.SetConfiguration(new MySqlEFConfiguration()); } }