Archive

Posts Tagged ‘Production’

Model Versioning

February 24, 2011 Leave a comment

Say you developed your application using CodeFluent Entities and shipped several versions of your application: how can you know from the code in production which model version was used to generate it?

First, in SQL a cf_modelVersion function is generated which allows you to retrieve a “model version number” indicating the model version used to generate the current SQL.

Likewise, in the generated Business Object Model (BOM), you’ll find something like this:

[assembly: CodeFluent.Runtime.Utilities.CodeFluentGeneratedAttribute("1.0.50204.0578", "CodeFluent Entities generated (http://www.softfluent.com). Date: Wednesday, 23 February 2011 22:20.", CodeFluent.Runtime.Utilities.CodeFluentGeneratedAttributeOptions.CompiledWithCodeFluent, 1431726511u)]

As you can see it also contains the same model version number: starting from the code, you can know which model version was used to generate them, and in addition, you can check that the BOM and SQL are consistent.

In fact, the CodeFluent Runtime even provides a method to do so programmatically:

CodeFluentPersistence.CheckModelMatchesDatabase(bomAssembly);

Updating a Production Database

February 15, 2011 Leave a comment

Here’s a tip on how to easily update the database of a CodeFluent Entities application that is already in production.

Say your application is already in production, and meanwhile you added some extra features, made some bug fixes, and etc. which in the end changed the schema of your database.

The trick to easily update the schema of your application is to leverage CodeFluent Entities’ diff engine to update your application.

To do so:

  • Backup your production database,
  • On your development environment, run your SQL Server producer on it!
  • Restore the updated database on the production server,
  • Don’t forget to update upper layers as well Smile

Modeler Overview

February 4, 2011 Leave a comment

Wondering how it goes to develop an application using CodeFluent Entities?

Check-out this video! Using the Modeler in Visual Studio 2010, you’ll see how to:

· Define entities,

· Define properties,

· Define enumerations,

· Collaborate,

· View the inferred Meta-Model (CodeFluent Entities is not template based generation!),

· Generate,

· Define instances,

· Generate continuously,

· Define methods,

· Add validation rules,

· Extend the generated code,

· Use the XML view,

· WPF Smart Client Producer,

· SharePoint Web Parts Producer,

· A custom ASP.NET MVC web site,

· Create a model from an existing application (Northwind).

 

SQL Hints

December 14, 2009 1 comment

CodeFluent Entities allows developers to specify SQL specific hints on its methods.

For instance, doing as so:

<cf:project xmlns:cf=“http://www.softfluent.com/codefluent/2005/1″
            xmlns:cfps=“http://www.softfluent.com/codefluent/producers.sqlserver/2005/1″>

 <Customer>
    <Id />
    <Name />
    <cf:method name=“LoadByName”
            body=“load(string name) Where Name=@name” cfps:tableHint=“NOLOCK“ />
 </Customer>
</cf:project>

Will generate a T-SQL stored procedure with the NOLOCK hint applied to the Customer table.

A recurring question that we have is “which SQL Server hints does CodeFluent support?“. Well the answer is very straightforward: all of them! Since, the applied hint isn’t inferred from the specified value, it means that regarding CodeFluent, you could specify anything! All that matters is that the specified hint is actually supported by the targeted platform.

For an exhaustive hint list, please check-out your SQL Server’s corresponding documentation:

CodeFluent Entities R&D Team

CodeFluent Entities and the SqlGeography Type

December 14, 2009 Leave a comment

Although there is not a geography type in CodeFluent Entities (as this is too specific to SQL Server 2008), you can still use the new SQL 2008 geography type today.

First you need to declare the target type in the CodeFluent Entities SQL Server Producer (with the ‘cfps:dataType’ attribute). Then, optionally, you can declare a computed companion property that will hold the data as the corresponding SQL Server 2008 .NET Type: SqlGeography.

It will work because these types can be transferred back and forth as arrays of bytes. Here is a sample model that does it:

Code:

<cf:project xmlns:cf="http://www.softfluent.com/codefluent/2005/1"
                   defaultNamespace="Test"
                   xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1">

 <Address>
  <Id />
  <RawSpatialLocation cfps:dataType="geography" typeName="byte[]" maxLength="-1" />
  <SpatialLocation typeName="Microsoft.SqlServer.Types.SqlGeography" persistent="false">
  <cf:rule typeName="OnGet" />
  <cf:rule typeName="OnAfterSet" />
  <cf:snippet name="SpatialLocation">

 private void OnGetSpatialLocation()
 {
  _spatialLocation = new Microsoft.SqlServer.Types.SqlGeography();
  using (System.IO.MemoryStream stream = new System.IO.MemoryStream(RawSpatialLocation))
  {
   using (System.IO.BinaryReader reader = new System.IO.BinaryReader(stream))
   {
    _spatialLocation.Read(reader);
   }
  }
 }

 private void OnAfterSetSpatialLocation(Microsoft.SqlServer.Types.SqlGeography spatialLocation)
 {
  using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
  {
   using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream))
   {
    _spatialLocation.Write(writer);
    _rawSpatialLocation = stream.ToArray();
   }
  }
 }
  </SpatialLocation>
 </Address>
</cf:project>

NOTE1: make sure Microsoft.SqlServer.Types.dll is referenced for the project to compile.

NOTE2: all this is valid for the SqlGeography, SqlGeometry and SqlHierarchyId types.

The next version of CodeFluent Entities will allow you to directly declare this:

Introduced with the latest CodeFluent Entities build (B31218), you can now do this:

Code:

<cf:project xmlns:cf="http://www.softfluent.com/codefluent/2005/1"
                  defaultNamespace="Test"
                  xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1"
                  assemblyPaths="c:\temp\Microsoft.SqlServer.Types.dll"> <!-- adapt this to your machine -->

 <Address>
  <Id />
  <SpatialLocation cfps:dataType="geography" typeName="Microsoft.SqlServer.Types.SqlGeography, Microsoft.SqlServer.Types" />
</Address>
</cf:project>

CodeFluent Entities R&D Team

What’s in CodeFluent Entities?

June 15, 2009 Leave a comment

For those of you wondering what really is in the product, here is a graph generated using the cool Visual NDepend tool, for a total of more than 110000 Lines of Code (metric defined by NDepend). What’s interesting is to categorize all these nice but hardly visible gray boxes. This is what we have done in the next image.

This is the same box, but with CodeFluent Entities features here arranged in 4 big categories: Import (reusing existing model or databases, and avoid loosing existing investments), Modeling (including the soon-to-come visual tools), Production (the real meat!) and Runtime support. As you can see, Modeling is still quite big, especially the in-memory model (the biggest box of all) built after parsing time. Runtime support has grown recently due to the recent SharePoint (WSS/MOSS) and Silverlight 2 support.

CodeFluent Entities R&D Team

Follow

Get every new post delivered to your Inbox.

Join 51 other followers