Home > Developing Using CodeFluent Entities, News, SoftFluent Products > Introducing the CodeFluent Entities Windows Store producer

Introducing the CodeFluent Entities Windows Store producer


In this article, we’ll see how to use the brand new CodeFluent Entities “Windows Store” producer.

We’re going to create a complete back-end application that will host web services exposing data which will be consumed by a Windows Store application.

I will use an existing model provided out-of-the-box by CodeFluent Entities for this demo, namely the “ContactManager” model.

Creating the solution

Since my Windows Store application is going to consume web services, I’ll need to do some work before I can add the “Windows Store” producer.

First, I’ll add two projects to my solution, a standard C# class library project and an empty Web Application project. My class library project will contain the CodeFluent Entities generated business entity classes, SQL scripts and WCF services. Here is what I will do for this:

· Add the “Business Object Model” producer, make it point to my class library project;

· Add a “Service Object Model” sub-producer to this producer. For this sub-producer I’ll specify “Enable JSON” as “JSON options” and I don’t want to produce a proxy so I’ll set the “Produce Proxy” property to “False”;

· Create a new folder named “Scripts” to my class library project which will contain my generated SQL scripts to generate my database. Note we could also create a specific “SQL Server Database” project to hold these files;

· Add a new persistence “SQL Server” producer, and set its target directory to the “Scripts” folder we’ve just created;

· Now, my empty web application project will host my standard WCF .svc files. To quickly generate these, I will add an instance of the “Template” producer (Add new producer > “Utility Producers” > Template). Since I want to generate JSON, I’ll specify for the “Source Directory” the “Services” folder located at “CodeFluent Entities installation folder > Modeler >Templates > ServiceModel > JsonWebServices > Services” and for the “Target Directory” my empty web application folder.

Adding the Windows Store project

I’ll now add a new Windows Store Visual Studio project, a JavaScript Grid App project. Note: this is the only project type supported by the CodeFluent Entities Windows Store producer for the moment. This is pretty much what we have to do regarding the Windows Store project.

Adding the Windows Store producer

Now that our standard Windows Store project is added, I’ll need to add an instance of the brand new CodeFluent Entities Windows Store producer to my model:

Screenshot (11)

Screenshot (12)

Since the Windows Store application will consume the web services that will be generated, I’ll need to reference the “Server Url“ in the Windows Store producer configuration. In this case, the “Server Url” is the URL of the web application I added earlier: http://localhost:49774/ (Please adapt to your settings). I’ll also set the “Base Services Url” to http://localhost:49774/Services.

Then I’ll set the “Target Directory“ property to point to the Windows Store project folder I added and leave other properties to their default values according to the screenshot below.

Screenshot (8)

I’m now ready to build all that!

Generating the code and launch the app

To generate, as usual, I’ll right click on my CodeFluent Entities project and hit ‘Build’.

Note: you may get back a CodeFluent Entities CF3708 error while trying to generate. It means the project attribute ‘createDefaultMethodForms’ is set to false. To set it to True, go to your CodeFluent Entities project properties, find the attribute in the ‘UI’ section, and set it to True. Starting with build 1.0.61003.684, the ‘createDefaultMethodForms’ attribute is set to True by default, on new projects.

Now that all our layers are generated, I’ll need to specify on my solution properties that I want multiple startup projects.

So I’ll set as first startup project my web application project which host my services and as second startup project my Windows Store application project like this:

Screenshot (13)

Now let’s hit ‘F5’ to run my projects and voilà! Here is my complete Windows Store connected application consuming my WCF/JSON web services, without a single line of code!

Screenshot (5)Screenshot (6)Screenshot (7)

Cheers,

Aymeric ROLAND.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 51 other followers