Pivot Script Producer - Bug Found - codefluent

I'm sorry to have to submit through this channel.
The report issue feature on your website won't just let me submit my request. Error enclosed:
SoftFluent, SoftFluent, we have a problem! An unidentified error has occured
Problem: Pivot Script producer crashes
Reproductible: Yes
Use case:
Basic use case is having 2 entities named the same (concept is the same but spreaded over different namespace and schema), yet referencing a third entity.
After extending SqlPivotProducer, it appears that referenced table would find its constraints (1 PK and 2 FK) but one of the 2 FK would have a null ReferenceTable leading to nullpointer.
Steps to reproduce:
Have this model below and try to generate Pivot Script File
<cf:project defaultNamespace="Model1" xmlns:cf="http://www.softfluent.com/codefluent/2005/1" xmlns:cfx="http://www.softfluent.com/codefluent/modeler/2008/1" xmlns:cfsps="http://www.softfluent.com/codefluent/producers.sqlpivotscript/2013/1" xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1" xmlns:cfspsi="http://www.softfluent.com/codefluent/producers.ixcyssqlpivotscript/2016/1" createDefaultMethodForms="true" createDefaultApplication="false" createDefaultHints="false">
<cf:import path="Default.Surface.cfp" />
<cf:entity name="Entity" schema="SchemaA" namespace="Model1.NamespaceA" persistenceName="Entity">
<cf:property name="EntityId" key="true" />
<cf:property name="EntityC" typeName="{0}.NamespaceC.EntityC" />
</cf:entity>
<cf:entity name="Entity" schema="SchemaB" namespace="Model1.NamespaceB" persistenceName="Entity">
<cf:property name="EntityId" key="true" />
<cf:property name="EntityC" typeName="{0}.NamespaceC.EntityC" />
</cf:entity>
<cf:entity name="EntityC" namespace="Model1.NamespaceC">
<cf:property name="EntityCId" key="true" />
</cf:entity>
<cf:producer name="SQL Server Pivot Script" typeName="CodeFluent.Producers.SqlServer.SqlPivotScriptProducer, CodeFluent.Producers.SqlServer">
<cf:configuration targetDirectory="..\Database1" connectionString="Server=127.0.0.1;Database=EntityA;Integrated Security=true;Application Name=Application;" cfx:targetProject="..\Database1\Database1.sqlproj" cfx:targetProjectLayout="Update" />
</cf:producer>
<cf:producer enabled="false" name="SQL Server" typeName="CodeFluent.Producers.SqlServer.SqlServerProducer, CodeFluent.Producers.SqlServer">
<cf:configuration produceViews="true" targetDirectory="..\Database1" connectionString="Server=127.0.0.1;Database=EntityA;Integrated Security=true;Application Name=FedPeche33_Association;" cfx:targetProject="..\Database1\Database1.sqlproj" cfx:targetProjectLayout="Update, DontRemove" produceSchemas="true" />
</cf:producer>
<cf:producer enabled="false" name="Asp.Net Identity" typeName="CodeFluent.Producers.SqlServer.IxcysSqlPivotScriptProducer, SqlServerPivotIxcys">
<cf:configuration targetDirectory="..\Database1" cfx:targetProject="..\Database1\Database1.sqlproj" cfx:targetProjectLayout="Update" connectionString="Server=127.0.0.1;Database=EntityA;Integrated Security=true;Application Name=FedPeche33_Association;" />
</cf:producer>
</cf:project>
Captured stacktrace:
System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in CodeFluent.Producers.SqlServer.dll
Additional information: Object reference not set to an instance of an object.
For the time being I would consider renaming my entities to go over this problem.
Thanks for your support
I also had this non-blocking exception on my environment while debugging pivot script generation:
DateTimeInvalidLocalFormat occurred
Message: Managed Debugging Assistant 'DateTimeInvalidLocalFormat' has detected a problem in 'C:\Program Files (x86)\SoftFluent\CodeFluent\Modeler\CodeFluent.Build4.exe'.
Additional information: A UTC DateTime is being converted to text in a format that is only correct for local times. This can happen when calling DateTime.ToString using the 'z' format specifier, which will include a local time zone offset in the output. In that case, either use the 'Z' format specifier, which designates a UTC time, or use the 'o' format string, which is the recommended way to persist a DateTime in text. This can also occur when passing a DateTime to be serialized by XmlConvert or DataSet. If using XmlConvert.ToString, pass in XmlDateTimeSerializationMode.RoundtripKind to serialize correctly. If using DataSet, set the DateTimeMode on the DataColumn object to DataSetDateTime.Utc.

Related

Unable to add custom prefix to generated views

I want to be able to add the prefix "cf_" to all stored procedures and views. I got it working with stored procedures but the same approach does not work with views. See screen shot for how I assigned custom prefixes.
Although I'm including the XML file, I prefer to use the property pages as opposed to editing the XML directly.
<cf:project defaultNamespace="DemoCustomPrefix" xmlns:cf="http://www.softfluent.com/codefluent/2005/1" xmlns:cfx="http://www.softfluent.com/codefluent/modeler/2008/1" xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1" xmlns:cfom="http://www.softfluent.com/codefluent/producers.model/2005/1" xmlns:cfasp="http://www.softfluent.com/codefluent/producers.aspnet/2011/1" defaultTargetFramework="4.0" defaultConnectionString="Database=DemoCustomPrefix;Server=.\SQLExpress;Integrated Security=true" persistenceSaveProcedureFormat="cf_{0}_Save" persistenceLoadProcedureFormat="cf_{0}_{1}" persistenceSearchProcedureFormat="cf_{0}_{1}" persistenceDeleteProcedureFormat="cf_{0}_{1}" persistenceRawProcedureFormat="cf_{0}_{1}" viewFormat="cf_{0}" procedureFormat="cf_{0}" createDefaultMethodForms="true" createDefaultApplication="false" createDefaultHints="false">
<cf:import path="Default.Surface.cfp" />
<cf:producer name="SQL Server Producer" typeName="CodeFluent.Producers.SqlServer.SqlServerProducer, CodeFluent.Producers.SqlServer">
<cf:configuration connectionString="Database=DemoCustomPrefix;Server=.\SQLExpress;Integrated Security=true" produceViews="true" targetVersion="Sql2008" targetDirectory="..\DemoCustomPrefix.Persistence" cfx:targetProjectLayout="UpdateItems, DontRemove" cfx:targetProject="..\DemoCustomPrefix.Persistence\DemoCustomPrefix.Persistence.dbproj" />
</cf:producer>
<cf:producer name="BOM Producer" typeName="CodeFluent.Producers.CodeDom.CodeDomProducer, CodeFluent.Producers.CodeDom, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1bb6d7cccf1045ec">
<cf:configuration compileWithVisualStudio="true" targetDirectory="..\DemoCustomPrefix" cfx:targetProject="..\DemoCustomPrefix\DemoCustomPrefix.csproj" />
</cf:producer>
<cf:producer name="ASP.NET WebForms Producer" typeName="CodeFluent.Producers.UI.AspNetProducer, CodeFluent.Producers.UI">
<cf:configuration categoryPath="UI\AspNetWebForms" targetDirectory="..\DemoCustomPrefix.Web" cfx:targetProject="..\DemoCustomPrefix.Web\DemoCustomPrefix.Web.csproj" />
</cf:producer>
<cf:entity name="Widget" namespace="DemoCustomPrefix">
<cf:property name="Id" key="true" />
<cf:property name="Name" />
</cf:entity>
</cf:project>
Figured it out. Just had to select "Custom Formats" under for Naming Convention.

Unable to remove date/time stamps on generated files

I am unable to remove the date/time stamps from the generated files.
The problem is, when I'm editing the .cfp file, I'll set the Production Flags to "Overwrite, RemoveDates". But soon as I save the file, the Production Flags automatically get re-written as "Default, RemoveDates". This happens at both the Producer and Project Level.
If I use the projects advanced properties to set the flags through the GUI, than it sets the Productions Flags to "Default, RemoveDates". Also I don't have the same flag options as in the screenshot at
http://blog.codefluententities.com/2013/04/22/remove-the-current-date-and-time-to-generated-files/
The screenshot has the following checked:
1. Remove Diffs: Remove Dates
2. Remove Dates
None of my options match those in the screenshot. The only one that appears similar is:
Remove Diffs <--- Note that the one in the screen shot has Remove Dates on the same line
Below is the model which was created using version/build 1.0.61214.805 of Codefluent Entities
<cf:project defaultNamespace="DemoRemoveDates" xmlns:cf="http://www.softfluent.com/codefluent/2005/1" xmlns:cfx="http://www.softfluent.com/codefluent/modeler/2008/1" xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1" xmlns:cfom="http://www.softfluent.com/codefluent/producers.model/2005/1" xmlns:cfasp="http://www.softfluent.com/codefluent/producers.aspnet/2011/1" defaultConnectionString="Database=DemoRemoveDates;Server=.\SQLExpress;Integrated Security=true" defaultProducerProductionFlags="Default, RemoveDates" createDefaultMethodForms="true" createDefaultApplication="false" createDefaultHints="false">
<cf:import path="Default.Surface.cfp" />
<cf:producer enabled="false" productionFlags="None" name="SQL Server Producer" typeName="CodeFluent.Producers.SqlServer.SqlServerProducer, CodeFluent.Producers.SqlServer">
<cf:configuration connectionString="Database=DemoRemoveDates;Server=.\SQLExpress;Integrated Security=true" produceViews="true" targetVersion="Sql2008" targetDirectory="..\DemoRemoveDates.Persistence" cfx:targetProjectLayout="UpdateItems, DontRemove" cfx:targetProject="..\DemoRemoveDates.Persistence\DemoRemoveDates.Persistence.dbproj" />
</cf:producer>
<cf:producer productionFlags="None" name="BOM Producer" typeName="CodeFluent.Producers.CodeDom.CodeDomProducer, CodeFluent.Producers.CodeDom, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1bb6d7cccf1045ec">
<cf:configuration compileWithVisualStudio="true" targetDirectory="..\DemoRemoveDates" cfx:targetProject="..\DemoRemoveDates\DemoRemoveDates.csproj" cfx:targetProjectLayout="Update" />
</cf:producer>
<cf:producer enabled="false" productionFlags="None" name="ASP.NET WebForms Producer" typeName="CodeFluent.Producers.UI.AspNetProducer, CodeFluent.Producers.UI">
<cf:configuration categoryPath="UI\AspNetWebForms" targetDirectory="..\DemoRemoveDates.Web" cfx:targetProject="..\DemoRemoveDates.Web\DemoRemoveDates.Web.csproj" />
</cf:producer>
<cf:entity name="Contact" namespace="DemoRemoveDates" categoryPath="/DemoRemoveDates">
<cf:property name="Id" key="true" />
<cf:property name="Name" />
</cf:entity>
</cf:project>
This article is pretty old. Try using this value instead:
productionFlags="Default, RemoveDates"
Or use the modeler to set this:
For the BOM producer, you need to set one more flag:
productionFlags="Default, Overwrite, RemoveDates"
You can also define it at model stage:

How do I convince the Visual Studio Publish Web wizard that my database is Entity Framework CodeFirst?

In VS2015 when I open an existing publish profile in the publish wizard, it immediately decides that my default database is no longer EF CodeFirst and removes the option to Execute Code First Migrations and replaces it with Update Database.
Somehow, the wizard seems to be deciding that this is no longer a CodeFirst Project and is replacing it with DbDacFx like so:
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="DefaultConnection" Order="1" Enabled="True">
<Destination Path="Data Source=*" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="m4d.Context.DanceMusicContext, m4d" MigrationConfiguration="m4d.Migrations.Configuration, m4d" Origin="Configuration" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
Transforms to:
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">
<Destination Path="Data Source=*" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=*" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\DefaultConnection_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="Data Source=*" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
(I replaced the various connection strings with *)
Anyone have any idea what the wizard uses to decide that this is a CodeFirst Project?
This article http://blogs.msdn.com/b/webdev/archive/2014/04/09/ef-code-first-migrations-deployment-to-an-azure-cloud-service.aspx provides some details of how to roll one's own version of the Execute Code First Migrations option, and is a potential workaround, but it used to just work.
In your .pubxml file, you must rename the ObjectGroup as the full name of your Dbcontext: m4d.Migrations.Configuration. Otherwise, it seems to be ignored.
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="m4d.Migrations.Configuration" Order="1" Enabled="True">
<Destination Path="Data Source=*" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="m4d.Context.DanceMusicContext, m4d" MigrationConfiguration="m4d.Migrations.Configuration, m4d" Origin="Configuration" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>

odatagen: Failed to generate proxy classes. Please verify the metadata (iOS)

Im working on Open Data Protocol (OData) which is a standardized protocol for creating and consuming data API's.
OData builds on core protocols like HTTP and commonly accepted methodologies like REST .
I have installed, configured and built OData successfully on iOS6
Currently I'm creating a Proxy class to connect to the OData Service using the following commands:
cd /Users/Shamsu/Applications/ODataObjC/ODataSDKV1-1.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug
./odatagen /uri=http://35.35.6.4/MyApp.MyApp3D.DataService/MyApp3DDataService.svc/ /out=/Users/Ramshad/Applications/ODataObjC/ODataSDKV1-1.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug /u=sa /p=123
However, I'm getting the error: "odatagen: Failed to generate proxy classes. Please verify the metadata"
I can see the "metadata.xml" file is updated as
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="MyAppDBModel" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="User">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="Edm.Guid" Nullable="false" />
<Property Name="UserName" Type="Edm.String" MaxLength="10" FixedLength="true" Unicode="true" />
<Property Name="UserDescription" Type="Edm.String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Active" Type="Edm.Int64" />
</EntityType>
</Schema>
<Schema Namespace="MyApp.MyApp3D.DataService" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="MyAppDBEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="User" EntityType="MyAppDBModel.User" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx> "
Note: the metadata.xml file is located at out param location (/Users/Ramshad/Applications/ODataObjC/ODataSDKV11.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug /metadata.xml)
I'm unable to identify the issue. Any problem with my windows WCF service /ODataService configuration/database configuration ? Permission assigned as * (read,write).
Any help on this issue is appreciated.
Thanks.
I looked a bit closer at the XSLT document I linked to in my original comment, and it seems that the odatagen tool hasn't been updated to work with CSDL v3. The version of CSDL (i.e., the format used to serialize the metadata document) is indicated by the xml namespace of the Schema element. In your metadata, that namespace is http://schemas.microsoft.com/ado/2009/11/edm, which indicates CSDL v3. You can see in the XSLT document here that this namespace isn't recognized by the odatagen tool.
Since the odatagen tool is open source (see the source on github), you can try to tweak the code and XSLT files to make it work for your situation. You could try to just add the v3 namespace to the recognized schema namespaces, and if your metadata doesn't use any v3 features, I would imagine it would just work. Off the top of my head I'm not sure of the exact differences between v2 and v3, so I can't immediately say whether the metadata you've posted above would be valid in CSDL v2.
Alternatively, you could try to generate the $metadata document so that it's using CSDL v2 instead.
Sorry I don't have a better answer for you. Unfortunately, the odatagen tool has fallen a bit behind. But you're more than welcome to contribute to the project :)

Are XSD type definitions validated at compile time?

In one of my projects, I used to have a WSDL element defined as having length of 20:
<xs:element name="LastName" type="mns:String20Type" />
Where String20Type is defined in an internal XSD:
<xs:simpleType name="String20Type">
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
To increase the length of that element, I changed String20Type to String40Type without adding a type definition into the schema and rebuilt:
<xs:element name="LastName" type="mns:String40Type" />
The build completed successfully without any error, warning, complaint or hint of any type.
Why?
How did the system know what String40Type is?
As requested:
Hmm... sounds like either Eclipse is not validating it properly or you have that type defined... somewhere. I use LiquidXML and Altova XML Spy. I suggest you try those specialized IDE packages and have them validate it and see where the error lies. They have free trials so give that a shot.