This page provides content to get you started using CodeFluent Entities. It assumes you have already downloaded and activated the product. If not, you can:
Once you are all set and ready go, let's get started!
In this section, we'll guide you through the import of an existing SQL Server database to a CodeFluent Entities model and the generation of a brand new .NET application from this new model.
Note: Since we need to start from an existing database, you'll need to download the "Nerd Dinner" sample application available on CodePlex so we can start from this provided database.
Open Visual Studio 2008 / 2010 / 2012, open the "CodeFluent Entities" menu and select the "Import an Existing Database or Model..." menu:
This will launch the Import Starter Wizard:
Click Next to create your Visual Studio solution:
Type-in:
Keep the "Import Starter Wizard" project template and click OK, to start importing your existing database.
The first step is to select which importer you're going to use:
In this case since we're importing the SQL Server 2008 NerdDinner database, we'll pick the "Microsoft SQL Server 2000 or higher database" importer and click Next.
On the next page you'll be able to define the connection string to connect to your existing database:
Please note that if you just want to import a subset of all tables available in the database you can do this using the "Table Names" property. Though not necessary for the NerdDinner database, this can be handy when working on big databases. For instance, here's what you'd see when importing the AdventureWorks database:
Now that your import is configured the wizard will propose you to save this configuration if desired so that starting over again you won't have to go through screens over again.
As import is now configured, following screens aim at preparing the brand new solution.
Start by selecting your architecture (Windows Forms Application for instance):
Your language (C#):
Your persistence layer (SQL Server in our case):
Once you selected your soon-to-be persistence layer (i.e. SQL Server for us), you need to define your target connection string (not to be confused with the one we defined earlier to import!):
Here, as you can see, I typed in a database name which does not exist yet, "NewNerdDinner", so CodeFluent Entities will create it for us. This way we won't alter the original "NerdDinner" one from which we're importing.
Note: Please note that you could totally generate on the original one if desired, however this topic bounds to illustrate how to create a brand new .NET application from an existing database.
Once this is done we're ready to finish this wizard which will:
Click finish and you'll see the magic happening :)
Now that you have a platform independent model representing your application, we'll generate some code from it. CodeFluent Entities will parse the designed model and infer an in-memory representation of this model. This inferred meta-model will then be passed to each declared producer which will translate this meta-model into code.
As you understood, a producer is a code generator and CodeFluent Entities provides about 20 different producers out-of-the-box. Completing the wizard as we did previously, the wizard automatically added and configured the following producers in our project:
As the producers were already added and configured by the wizard to generate code in our target projects: all we have to do is build our project.
To do so, right-click on your CodeFluent Entities project, and select "Build". CodeFluent Entities will:
Build the project, verify that everything compiles and you're good to go!
Now that we created our application's database and API, let's create a UI using the generated code.
namespace NerdDinner.Client { public partial class MainForm : Form { private Random _rand; public MainForm() { InitializeComponent(); _rand = new Random((int)DateTime.Now.Ticks & 0x0000FFFF); } private void OnRefreshButtonClick(object sender, EventArgs e) { _dataGridView.DataSource = DinnerCollection.LoadAll(); } private void OnCreateButtonClick(object sender, EventArgs e) { Dinner dinner = new Dinner(); dinner.Title = "Sample Dinner #" + _rand.Next(10000); dinner.Description = "Yet another nerd dinner."; dinner.HostedBy = "SoftFluent"; dinner.EventDate = DateTime.Today; dinner.Address = string.Format("{0} Main Street", _rand.Next(1000)); dinner.ContactPhone = string.Format("{0}-{1}-{2}", _rand.Next(100, 999), _rand.Next(100, 999), _rand.Next(1000, 9999)); dinner.Country = "USA"; dinner.Save(); } } }
<?xml version="1.0"?><configuration> <configSections> <section name="NerdDinner" type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" /> </configSections> <NerdDinner connectionString="database=NewNerdDinner;server=SFCAN03;Trusted_Connection=true" /> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup></configuration>
Compile and run the project and here's what you should get:
"As a service company, CodeFluent Entities empowers us to stand out at low cost while reducing implementation risks."
I have used CodeFluent Entities for over 2 years and it has completely changed my way of implementing .NET applications. I can't do without it any more!
SoftFluent sales staff have been responsive without being pushy and it’s refreshing to find a company that knows the quality, support and productivity improvements available through their product is more important to developers than anything else.
Technical articles on the product.
Ask a question to the whole community and our product teams.
Need help? We're here to help you!
Watch product demos online
Are you a Microsoft or Infragistics MVP?Then ask for your free Ultimate license now!
A double-sided sheet listing key information related to the product.
A document to understand the benefits of Model-First Software Development.
A document to better understand the relative positioning of the product.
SoftFluent 2018 156th Avenue NE - Bellevue, WA 98007 - USA Phone: (+1) 425 372 3047 - Email: info@softfluent.com Copyright © 2005-2013 SoftFluent