0

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
1
  • Is there a reason you're trying to assign the connection? Why not just let EF create it? It's possible to do this, but it's not the easy way, and I wouldn't want to do it without a really good reason why. Commented Feb 15, 2011 at 17:35

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.