I didn't update the stuff in the toolkit because EFCF 5.0 requires .NET 4.5 and I don't want to force .NET 4.5 just yet.
I'll be rev'ing the library when I get some free time to move all of it to .NET 4.5.
+++ Rick ---
WAIT!!! I found the problem...
The only issue was that I did not have the Connection String defined in my Web.Config file of the MVC app. I had it in the App.config file of the Bus Obj project I had used to create the entitites, but I did not realize that I needed to copy it into the Web.Config also.
When I first ran against your EfCodeFirst stuff, it kind of failed silently, telling me it could not find a match on the passed Id. However, it turns out this was not the real problem...
So when I gave up on your EfCodeFirst, and took a step back to just native EF5 Code First, when I ran it the first time, it complained that it could not find the specified Connection String.
<code>
No connection string named 'QuoteContext' could be found in the application config file.
<<</code>>>
I knew the Connection String was in App.Config of the Bus Obj project, so I added it the Web.Config of the MVC project, and tehn native EF5 Code First worked fine.
I then tested your EfCodeFirst again, and then it worked.
So, Boom! Now running your EfCodeFirst re-compiled on EF5.
Woohoo!!
OK, so this is basic usage. I guess it's possible I could still have issues with some parts your EfCodeFist running against EF5, since you didn't write it to that version yet, so there is still some testing to do.
Rick - I see that your EFCodeFirst wrapper is currently based on EF 4.3.1.
To get started using this thing, I created a new project for my data tables and loaded in EF 5 using Nuget package manager, and then I ran the generator from EF Power Tools to create my entity classes and default mapping classes. I also added a reference to your EfCodeFirst assembly, and created an EfCodeFirstContext and a bus class based on EfCodeFirstBusinessBase (you have shown us how to do this in a previous post, and I just followed that pattern). However, at run time, there was a DLL conflict on the EF dll. No surprise here... My project using is EF5, and your EFCodeFirst is using 4.3.1.
So, I tried to "update" your EFCodeFirst to use the EF5. I updated your Project to EF 5 via Nuget updater. I had to change a few namespaces to get rid of errors, but I was eventually able to get it compile with no errors.
However, when my app runs and I use an instances of the EfCodeFirstBusinessBase bus class, and I call the Load() method with an integer value point to a PK, it says that it cannot find the record.
I know my entity classes and Sql Server setup are good, because I can use the native EF5 DbContext and calling their Find() method, I am able to find that record just find.
So, there must be more to updating your EFCodeFirst package to EF5 than my little brain can currently figure out.
Do you have any plans to update it to EF5?
The main difference is you can't use the designers for Code First. Once imported you have to manage the data structures in code. OTOH, you can drop all the entities into a Class Diagram and it'll give you at least some semblance of a view for the data (sans the relationships).
+++ Rick ---
Yep, even though it’s called “Code First”, you can still generate the “Code” part (i.e. the entity classes), from the database using a Visual Studio tool to create them. After the initial export from the database, you’d probably just manually keep your class properties in sync with any table schema changes. The tooling
So this weill get you the classes and some defatul mapping, and some initial contexts set up.
The thing Craig and I are interested in is the sweet wrapper methods around these contexts like Find() and Save() that you spoiled us with in wwBusiness.
Here is a 6 minute video from Microsoft titled “Code First to an Existing Database”
http://msdn.microsoft.com/en-us/data/jj200620.aspx
And, here is a link to the Entity Framework Power Tools needed to do the code generation:
http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
I haven't used Entity Framework classic for a project so there's no real time experience on that code.
Frankly I'd advise against using classic EF. From what I've heard all new development will go into CodeFirst, with eventual merging of the tooling into the CodeFirst output generation. You can already import databases to Code First using the EF PowerTools which generate the EF CodeFirst classes for you and keeping in synch has never really been support by the EF designers anyway.
+++ Rick ---
Hi Rick,
Matt and I are "Entity Framework Diving" again and have a question regarding WWW & Ajax Toolkit.
Our Database(s) are already defined. We have studied "EfCodeFirst" and "LinqToSql" and are very interested in "EntityFramework"; however, "EntityFramework" is still labeled (experimental). What is left on this one to take it off the experimental list and use extensively as our "go to" .net business object wrapper?
Thanks, Craig & Matt
You have that code in West Wind Ajax and Web Toolkit. :-)
I'll be looking at this when I get back from India. I have a new project I can try EF out on and will be updating that code base. The big problem is that a lot of the stuff is so much less configurable than L2Sql was which makes it so much less friendly to high level abstraction...
+++ Rick ---
Are you anywhere close to an EF wrapper? I've been looking around for EF 4 Repository packages, and there are a few that keep popping up on Google, but none that I'd trust as much as something from you!
EF is in CTP5 righ now. Surely they must be getting close to something stable.
Come, on, give us some good news...
Haven't given it much thought recently. It'll need some time to test once .NET 4.0 releases next week...
+++ Rick ---
Well, that good news... But, you mean even this late in the game, with the VS2010 and .Net 4 launch next week, that they are still playing with the EF bits? I would have thought that stuff was locked down by now.
Anyway, I'll begin my EF work when you release this... So far, I've not even touched it, but it is on my list of things to learn, especially now that I know about your wrapper.
How will you release it? Like a White Paper kind of thing? Or as part of your Toolkit for ASP.Net, or maybe even a separate package?
Hey Rick - I really love the simple Business Object Wrapper for LinqToSql that you wrote. It is awesome, and makes CRUD data access a piece of cake.
I wanted to ask if you have any plans to create a similar version of this Entity Framework?
Or, do you know of a simple, light weight version that someone else has already created that I can experiment with?
I have one that provides roughly the same functionality, but I haven't put it out yet because there are still changes in EF coming that will affect it. Once VS 2010/.NET 4 ships I'll see about providing the EF layer as well...
+++ Rick ---