I am upgrading my practice Entity Framework code to v4.1. In old version, I had my context class deriving from ObjectContext but with new release of EF 4.1, they have provided a good DbContext API.
I am basically trying to convert the code so that it works from Database First approach to Code First approach. Playing around with EF 4.1
In old code, I had something like
context.Connection.BeginTransaction(isolationLevel);
where the context Type was deriving from ObjectContext.
In v4.1 I haven't got access to Connection property from context. How can I do that?
Open the edmx (go to properties, the connection string should be blank), close the edmx file again. Open the app. config and uncomment the connection string (save file) Open the edmx, go to properties, you should see the connection string uptated!!
A DbContext instance represents a combination of the Unit Of Work and Repository patterns such that it can be used to query from a database and group together changes that will then be written back to the store as a unit. DbContext is conceptually similar to ObjectContext.
It is in the DbContext and it should be public.
dbContext.Database.Connection.ConnectionString
also:
dbContext.Database.Connection.BeginTransaction(isolationLevel)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With