I would like to work with DbContext instead of ObjectContext. I updated EF so now I have the DbContext, but I want to generate my strongly-typed context based on the DbContext and not the ObjectContext. When I add new ADO.NET Entity Data Model, it is still based on the ObjectContext. Is it not possible to have it base off of DbContext in Visual Studio 2010 with EF 4.1?
UPDATE:
Okay, I followed the directions in this link and was able to generate the DbContext template objects. However, now it is saying there is ambiguity between the template entities and the entities in my .edmx file. How do I resovle this? Do I blow away the ones in the .edmx file?
EF is built on top of ADO.Net, meaning that you can use both at the same time.
Adding an Entity Data Model To add an Entity Data Model to your solution, do the following: In the Solution Explorer, right-click your application and select Add and then New Item. From Visual Studio installed templates, select ADO.NET Entity Data Model (see the figure that follows). Click Add.
To use code-first for an existing database, right click on your project in Visual Studio -> Add -> New Item.. Select ADO.NET Entity Data Model in the Add New Item dialog box and specify the model name (this will be a context class name) and click on Add. This will open the Entity Data Model wizard as shown below.
Okay, I got this to work by right-clicking in the .edmx diagram view and selecting 'Add Code Generation Item...' and then selecting 'EF 4.x DbContext Generator' from the options. It worked perfectly.
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