This is a continuation of SoftFluent’s CodeFluent Entities evaluation which I started in Part 1. Please see if before continuing here. Continuing with the CodeFluent Entities tutorial I’ll generate some code which can be used for different data store technologies. (This reminds me of Microsoft’s Entity Framework’s Code First way of generating storage entities.) CodeFluent Entities has 20 different providers that it can work with from the get go. The next step is to add a class library project to the OrderProcess solution. We’re going to name this new project OrderProcess. Remember in Part 1 we created a CodeFluent Entities project named OrderProcess.Model, so no conflict in project names. We delete the default class Class1 from the project. We add a folder named “Persistence Scripts” to this project, which will have the SQL scripts that will generate the SQL Server scripts. In order to add this functionality we need to add a SQL Server Producer to the original OrderProcess.Model project. In there is a Producers folder, right clicking on it will bring up the Add New Producer dialog: According to the instructions for the tutorial we’re to open up the “Persistence Layer Producers” node. However, before doing that I did some poking around to see what else was available. Under the “Application Producers” node there’s things like Microsoft Office Lists, including lists from either MS Access of Excel. I also see “WPF CllickOnce Smart Client”, which apparently is in beta. This is of interest to me, as I’ve done some WPF development, and so I might come back later and see what that could lead to, but will have to save that for another time. There’s “Business Layer Producers”, which only has “Business Object Model”. The “Utility Producers” includes Entity Framework! It also has command line execution and Silverlight Object Model. And the last in the list on the dialog box is “Web Producers”, which has things in it like ASP.NET Web Controls and ASP.NET Web Service both labeled legacy. I would presume this means things like .asmx and possibly WCF. There are other things under “Web Producers”. It also includes SharePoint WebParts, which I imagine would be of interest to SharePoint developers. But in this case we’re working with the “Persistence Layer Producers”, which is for database types like MySQL, Oracle, PostgreSQL, SQL Server and SQL Server Azure. For this purpose I’m working with SQL Server, so I’ll select that. I then get this: As you can see there’s a validation error here, but that’s because we’ve got to specify a folder to put the scripts generated. Here we choose that “Persistence Scripts” folder that we created in the new OrderProcess project. This pops up a Browse for Path or Project Folder dialog, which looks like this on my machine: The next step wasn’t too obvious to me, but what you had to do was click on the empty textbox next to Connection String in the Add New Producer dialog. According to the tutorial instructions it says you’re to, “Click in the cell corresponding to the ‘Connection String’ value and type-in your connection string thanks to the ‘Connection String Editor’ window and click OK to validate the connection.” At this point I don’t know what my connection string is, as I don’t have a database out there to use. What I believe we’re to do is click on the button with the three dots in it that you see when you click on the textbox next to “Connection String”. Clicking on that you then get this: My connection string looks different from what’s in the instructions, but that might be de to the version of SQL Server I’m using. (I’m using SQL Server 2014 Developer Edition.) I clicked on the Test Connection button, which is my habit. It couldn’t find the database, but it did suggest that it might be because the database doesn’t yet exist, which certainly is true. Or I could use the Master database, which I certainly do not want to do! Nevertheless, this s helpful. According to the instructions CodeFluent Entities will create the database if it doesn’t exist, so I’ll click on the OK button instead. Clicking OK on the Add New Producer dialog adds the producer to the OrderProcess.Model project. My solution explorer now looks like this: Next we’ll add a business object model producer. Going back to the Producers folder in the OrderProcess.Model project, we once again right click on the Producers folder, but this time we choose Business Layer Producers and under that Business Object Models. Once again you’ll see that the Target Directory has a validation error, but that’s only because we’re just adding this producer. In tis case we’ll select the OrderProcess folder and click OK. (I think it is important to point out here that “Business Object Model” doesn’t mean something related to Crystal Reports. I made that mistake, so don’t think that it has anything to do with Crystal Reports.) Here is how the Add New Producer dialog now looks on my machine: At this point we’re ready to build our solution, so I do a Control+Shift+B to build it. When I did I got the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
I believe this is caused by the server name in the connection string dialog box being 127.0.0.1. I’m going to go into the connection string dialog box and change that to include (Local). I got to that by double clicking on the SQL Server producer so I could go to the connection string. This is how I changed it: Now let’s try that build again. That fixed that problem. So if you encounter that error I got above, change your connection string to not use the IP address, but instead use local for your SQL Server. (Note: I am doing this with the local, default instance of SQL Server on my development box. Naturally if you’re using a named instance or a SQL Server instance remotely, then make appropriate adjustments.) Now that we’ve got the build to work, it generated a lot of the code to generate necessary SQL objects. The SQL scripts are written in the Persistence Scripts folder. I’ll continue this in part 3 of this evaluation.