This project has moved. For the latest updates, please go here.

No Database

Oct 17, 2013 at 11:56 AM
Hello,

I tried Effort with a Database First edmx and didn't have any problems. In my project I decided to reverse engineer the database by using the entity framework power tools and then refactor the context assembly - split it up in a POCO assembly and a context assembly. I also implemented generic repository pattern and unit of work pattern (together with MEF2 as DI container). Now as there is no edmx file and espacially no metadata I thought I have to go the "DbConnection-Way". So in my Unit Test I did the following:
 IDataLoader loader = new CsvDataLoader(thePathToTheCsvFilesCreatedWithCsvTool);
            DbConnection dbConnection = Effort.DbConnectionFactory.CreateTransient(loader);
            using (var ctx = new TheContext(dbConnection))
            {
                // real ef
                //TheContext ctx = new TheContext();
                IUnitOfWork uowtest = new UnitOfWork(ctx);
                var resulttest = uowtest.Repository<Question>().FindById(94420);
            }            
If I run this example with the EF context everything works as expected. If I use Effort I get stuck at the FindById-Row. I get a NullReferenceException in DbExtensions.GetTable and the Database parameter is null. I downloaded and included the source code to see where the database is being created but got also stuck because no inializing method will be hit and I don't know where database creation should happen in my Code First scenario.

Any help how to retrieve more information about my issue - so I can make it an issue - would be helpful. I don't know what's going on at all. It's just that there is no database inside dbcontainer?!
Coordinator
Oct 20, 2013 at 9:31 PM
Edited Oct 20, 2013 at 9:32 PM
Hello,

If you inserted the following code before the creation of UnitofWork, would it run properly?
ctx.Database.CreateIfNotExists();
Oct 21, 2013 at 7:36 AM
Hello,

thank you for your answer. I tried this and it didn't work. I ran into a configuration issue and according to http://effort.codeplex.com/discussions/435498 I added the Line in the config. the NuGet-Version didn't work so I switched back to the source code version (added Effort and Effort.CsvTool to the solution). So now when I try to let the context create the database it says that Effort.Provider.EffortProviderServices didn't return an object that was derived from System.Data.Entity.Core.Common.DbProviderServices which is necessary when using EF6. In the source code of class EffortProviderServices I can see that it is derived from System.Data.Common.DbProviderServices. So I guess with EF6 they refactored namespaces which isn't reflected by Effort yet?!

I keep on tracking this thread - I hope I can help to get Effort working with EF6. Meanwhile I use plain mocking everything and L2O to go ahead with some unittests. I will switch back to Effort as soon as I can get it running, because I think this is a great project!
Coordinator
Oct 21, 2013 at 9:38 AM
Edited Oct 21, 2013 at 9:38 AM
There are separate builds for EF6 and pre-EF6. Currenly there is no package published on Nuget.org that supports EF6, however if you downloaded Effort from the Codeplex you would find one.

Also you can always check the nightly build repository that contains releases (both Nuget and zip packages) compiled from the most recent source code:
http://development.flamich.net/oss-nightly/
Oct 21, 2013 at 10:20 AM
Uh, stupid me! THAT hint helped a lot. I built the assembleys seperately, included them in my solution and now the problem last mentionend has gone.

Stuck now at the creation of the database. Seems like I have trouble with PKs including more than 1 column. Investigating this. I've got to admin that the "grown database schema" is not a good condition, ie still uses numeric(19,2) as PK but that works.
Oct 21, 2013 at 10:26 AM
LoL .. okay .. and I do have a key with 9(!) members in that "old grown database schema" .. so I get a "memberTypes" exception in TypeHelper.GetTupleType .. but I guess this all has to do with the database I have to use.
Oct 21, 2013 at 11:58 AM
Okay, now, thank you for help. All my issues are solved. Effort works like a charme for me now. I took the wrong version (pre-ef6 instead of ef6) and a have to use a not very normalized existing database where some tables don't have PKs so the entity framework powertools generates mappings with PKs that have ALL columns included whcih might be more than 8.

For a quick test I changed alle those generated PKs to just 2-3 columns and the database gets created, filled with the data from the csv and my query via generic respository und unitof work works perfectly.

Thank you very much for helping me!
Coordinator
Oct 21, 2013 at 3:18 PM
You are welcome!

I will fix that "many field pk" issue.
Oct 22, 2013 at 7:02 PM
I checked in the nighlies nuget server (http://development.flamich.net/oss-nightly/) for an EF6 version, but there is only a version there that requires EF6-RC1. Can you point me explicitly to a version that supports EF6 RTM? The versions on Codeplex are from April.
(There are separate builds for EF6 and pre-EF6. Currenly there is no package published on Nuget.org that supports EF6, however if you downloaded Effort from the Codeplex you would find one.

Also you can always check the nightly build repository that contains releases (both Nuget and zip packages) compiled from the most recent source code:
http://development.flamich.net/oss-nightly/
Thanks,

Paul
Coordinator
Oct 23, 2013 at 1:16 AM
Check the most recent release on the nightly build server, it has the desired package now.

In the near future I am going to upload an EF6 RTM compatible package to Codeplex and NuGet too.
Oct 23, 2013 at 1:49 AM
Thanks!

Sent from my iPhone

Coordinator
Nov 17, 2013 at 11:00 PM
Recent release should solve the large concatenated primary key problem.
Nov 19, 2013 at 1:35 PM
Hello,

thank you very much. But meanwhile I kicked some asses to get the database normalized as it is supposed to be - now there is a single column identity primary key in every table. ;)

Again thank you for your exciting project and your support.
Marcus