Entity Framework CTP5: How to connect MySql database using C#?
I am trying to use Entity Framework CTP5, from a simple project. for now i added the reference to EntityFramework.dll (CTP5) and then write some code. But now i am unable to use it:
How to connect MySql database using C# ?
for now i created:
public class EF5_DATABASE : DbContext
{
public DbSet<Sistema.Clientes.Cliente> Clientes { get; set; }
}
but the following code is not working:
EF5_DATABASE db = new EF5_DATABASE();
db.Database.Connection = ERP.MyConnection; // MyConnection is a connected MySqlConnection
it throws this compiler error:
Error 8 Property or indexer 'System.Data.Entity.Database.DbDatabase.Connection' cannot be assigned to开发者_开发知识库 -- it is read only C:\inetpub\wwwroot\temp\WpfApplicationTEST\MainWindow.xaml.cs 48 13 WpfApplicationTEST
We have written an article illustrating some aspects of EF CTP 5 Code First support in dotConnect for MySQL.
Hope this article will be helpful.
精彩评论