Archive

Archive for the ‘Importers’ Category

Create your model from the Visual Studio Server Explorer

March 13, 2014 1 comment

CodeFluent Entities provides model importer capabilities which allows you to create model from an existing database or from an existing model.

In the past, we covered lots of topics about these features but do you know you can also create your model from the Visual Studio Server Explorer?

Server Explorer

Open the server explorer and configure your database connection.

Wizard

Then select tables and drag and drop them onto your CodeFluent Entities Surface. The importer wizard opens with preconfigured values. Click the “next” button and your entities will be created.

Model importer

Don’t forget that CodeFluent Entities is shipped with the following importers:

  • Microsoft SQL Server importer,
  • Microsoft SQL Server CE importer,
  • Microsoft Access importer,
  • Oracle Database importer,
  • OLE DB Importer,
  • PostgreSQL importer,
  • MySQL importer,
  • SQLite importer
  • Enterprise Architect importer,
  • XMI importer,
  • Entity Framework importer.

More information about CodeFluent Entities Importer Wizard.

Happy importing!

The R&D team

Defining type mappers when importing a database using the Importer Wizard


You can use the Importer Wizard to import an existing data base as a CodeFluent Entities model. You can access the Importer from the Modeler or the solution explorer on your CodeFluent Entities project (right click).
 

The Importer Wizard

The Importer Wizard


 
The importer makes a mapping between the data source types and the CodeFluent Entities types. But, you may want to define your own mapping configuration for a given type.
 
To do that, go to the “advanced properties” of the Importer Wizard and select “Type Mappers” under the “Input Mapping” group and add your type mapper.
 
Type Mappers Configuration

Type Mappers Configuration


 
Add an Importer Type Mapper

Add an Importer Type Mapper


 
Let’s say I am importing a SQL Server 2012 database and I have a field of type “time” (more information about SQL Server 2012 type mapping here), well I would like to have a CLR type “TimeSpan” mapped to it. When I take a look at the imported model I can see that the mapped type is “time”, but when I generate the Business Object Model (BOM) layer I have a property of type “System.DateTime (nullable)”. This is because the SQL Server type “time” did not exist before the SQL Server 2008 version.
 
SQL Server time type

SQL Server time type


 
time to DateTime mapping

time to DateTime mapping


 
So we can define a “type mapper” for the SQL Server type “time”.
 
elapsedtime mapper

elapsedtime mapper


 

We could also have chosen “System.TimeSpan”, “timespan” or “duration” as the “Type Name”.

 
And now we have a CLR type “System.TimeSpan (nullable)” in our BOM for a SQL Server 2012 type “time”.
 

time to TimeSpan mapping

time to TimeSpan mapping


 

Remember that you can save your Importer Wizard configuration.

 
You can find more resources about the Importer Wizard here.
 
 
Regards,
 
Pablo Fernandez Duran
 
 

Goodbye SQL-DMO!

September 10, 2012 1 comment

Starting with build 671, SQL-DMO is not longer a requirement for the CodeFluent Entities SQL Server Producer. That’s good news!

We have been relying on SQL-DMO for almost 7 years, and it has served us well. It has been marked as obsolete for something like 5 years or so, but the producer was still relying on it. One of the reasons we kept it for so long was to maintain  compatibility with SQL Server 2000. Now, we don’t support that database either (june 2012).

We have replaced SQL-DMO by a similar technology without any dependency on the newer SQL-SMO (replacement for SQL-DMO) either. This database abstraction technology – our own SMO-like layer – works not only for SQL Server but also for all our supported importers and producers supported databases and modeling systems, namely: SQL Server, Oracle, PostgreSQL, MySQL, SqlLite, Xmi, Enterprise Architect, Access and SqlServerCe. It’s mainly located in the CodeFluent.Runtime.Database.dll assembly that ships with the product and in satellite ones for specific targeted systems (CodeFluent.Runtime.PostgreSQL.dll for PostgreSQL, CodeFluent.Runtime.MySQL.dll for MySQL, etc.).

Cheers,

The R&D team.

CodeFluent Entities: Import SQLite databases

August 2, 2012 Leave a comment

Starting with CodeFluent Entities 669 available here, you can import SQLite databases into CodeFluent Entities models Smile

Several ways to import your existing database:

  • Option #1: From the Solution Explorer, right-click on your project and click “Import An Existing Database or Model…”,
  • Option #2: From the Server Explorer, drag and drop tables from your database onto your surface (this won’t work for SQLite unless you have added the SQLite Visual Studio tools I guess…),
  • Option #3: From the Visual Studio toolbar (builds 661 and upper), open the “CodeFluent Entities” menu and click on “Import An Existing Database or Model…

Whichever option you choose, the same wizard will open and it now contains a new importer: SQLite.

CodeFluent Entities SQLite Importer

Prerequisites

  • CodeFluent Entities (build 669 or upper),
  • The SQLite NET Data Provider accessible by CodeFluent Entities so it can connect and import the database to your model. To do so place the System.Data.SQLite.dll in CodeFluent Entities’ installation directory (%ProgramFiles(x86)%\SoftFluent\CodeFluent\Modeler). This provider is downloadable from here: http://system.data.sqlite.org. We suggest you take the “Precompiled Statically-Linked Binaries for 32-bit Windows”, bundle version.

Cheers,

The R&D team

CodeFluent Entities: How to reuse existing stored procedures

July 13, 2012 Leave a comment

In this post I’ll start from the NerdDinner application, which you can get from CodePlex (http://nerddinner.codeplex.com/). In the NerdDinner database I added the following sample stored procedure named “sp_SelectDinnersByCountry” that takes a county name as a parameter:

CREATE PROCEDURE [dbo].[sp_SelectDinnersByCountry] 
(
     @Country [nvarchar] (50)
)
AS
SET NOCOUNT ON
SELECT DISTINCT * 
    FROM Dinners 
    WHERE Country = @Country
RETURN

From there, I then imported the NerdDinner database into a brand new CodeFluent Entities model (as detailed on CodeFluent Entities’ Get Started page) and now what I want to do is to reuse my existing stored procedure, instead of creating a new one using CFQL.

Select the “Dinner” entity and add the following new method:

image

Now that our method is created we need to specify:

  • it’s name in the persistence layer as my stored procedure has a different name than the one in my model,

image

 

  • it’s return type (by default raw methods are void),

image

 

  • mark my method so it’s not generated by the SQL Server Producer,

image

 

As a consequence the Business Object Model Producer will generate a SelectByCountry method, which calls the sp_SelectDinnersByCountry stored procedure, and returns a DataSet, so now in my app I can do something like this:

System.Data.DataSet ds = Dinner.SelectByCountry("FRANCE");

 

Hope this helps,

Carl

CodeFluent Entities: Saving import configurations

July 11, 2012 1 comment

Using CodeFluent Entities you can import existing databases (Access, SQL Server, SQL Server CE, Oracle, MySQL, PostgreSQL) or existing models (Enterprise Architect, XMI, ADO.NET Entity Framework) into CodeFluent Entities models. The idea behind this import feature is that you’ll import your existing line of business once (see the Importers category for more info on this) and then drive your developments from your CodeFluent Entities model, as CodeFluent Entities is a model-first tool.

Recently we added the possibility to save and load import configurations so you can keep your settings and work on your import over and over again until the model imported tastes good.

For instance, let’s create a brand new blank model that we’ll name Northwind.Model and which will be a CodeFluent Entities version of Microsoft’s sample Access 2010 database Northwind.

image

Right-click and on your project and select “Import an Existing Database or Model…”, select the Access importer, configure it, hit next, next, next and you should get to this screen:

01-MyImportConfig

By saving it, we’ll be able to run this import with the exact same configuration without having to configure everything over again.

For instance, by importing the Northwind sample database for Access 2010 keeping the default settings, we get a String table which I don’t want in my .NET application.

Let’s delete all my entities in my model and import over again using the same import configuration (MyImportConfig.cfi):

02-MyImportConfig

Once this is done, let’s customize our import settings and specify in the “Table Full Name Filters” the “String” table name that we want to skip:

03-MyImportConfig

Let’s save our new config and import over again, tadaaaa, no more String entity:

image

Cheers,

Carl Anderson

CodeFluent Entities: Import MySQL and PostgreSQL databases


Starting with CodeFluent Entities 60529.661 available here, you can import MySQL and PostgreSQL databases into CodeFluent Entities models Smile

Several ways to import your project:

  • Option #1: From the Solution Explorer, right-click on your project and click “Import An Existing Database or Model…”,
  • Option #2: From the Server Explorer, drag and drop tables from your database onto your surface,
  • Option #3: This is brand new with the latest build (661 and upper), from the Visual Studio toolbar, open the “CodeFluent Entities” menu and click on “Import An Existing Database or Model…

Whichever option you choose, the same wizard will open and it now contains two new importers: MySQL and PostgreSQL.

ImportWizard

 

Prerequisites

  • CodeFluent Entities (build 60529.661 or upper),
  • MySQL or PostgreSQL .NET Data Provider depending on which database you want to import.

In both cases you’ll need the appropriate .NET provider to be accessible by CodeFluent Entities so it can connect and import the database to your model. To do so place the MySQL.Data.dll for MySQL or Npgsql.dll for PostgreSQL in CodeFluent Entities’ installation directory (%ProgramFiles(x86)%\SoftFluent\CodeFluent\Modeler).

 

Cheers,

Carl Anderson