Solr delete won't work after schema update - solr

I'm using SolrNET to post documents to the Solr index, as well as remove documents from the index.
This has been working until now.
What I've done is this:
In schema.config, added a string field (this new field stores a GUID) instead of the earlier UUID field
Restarted Tomcat
(I switched from the UUID field to string field because it didn't work well for me, but that's another story.)
Here is what my schema.config looks like:
<fields>
<field name="id" type="int" indexed="true" stored="true" required="true" />
<field name="searchobjecttype" type="string" indexed="true" stored="true" required="true" />
<field name="heading" type="text" indexed="true" stored="false" required="false" />
<field name="body" type="text" indexed="true" stored="false" required="false" />
<field name="locationid" type="int" indexed="true" stored="true" required="false" />
<field name="currentlocationid" type="int" indexed="true" stored="true" required="false" />
<field name="countryid" type="int" indexed="true" stored="true" required="false" />
<field name="currentcountryid" type="int" indexed="true" stored="true" required="false" />
<field name="forumroom" type="int" indexed="true" stored="true" required="false" />
<field name="forumtopicid" type="int" indexed="true" stored="true" required="false" />
<field name="dt" type="date" indexed="true" stored="false" required="false" />
<field name="txt" type="text" indexed="true" stored="true" multiValued="true" />
**<field name="guid" type="text" indexed="true" stored="true" required="false" />**
</fields>
<copyField source="id" dest="txt" />
<copyField source="searchobjecttype" dest="txt" />
<copyField source="heading" dest="txt" />
<copyField source="body" dest="txt" />
<copyField source="locationid" dest="txt" />
<copyField source="currentlocationid" dest="txt" />
<copyField source="countryid" dest="txt" />
<copyField source="currentcountryid" dest="txt" />
<copyField source="forumroom" dest="txt" />
<copyField source="forumtopicid" dest="txt" />
<copyField source="dt" dest="txt" />
**<uniqueKey>guid</uniqueKey>**
<defaultSearchField>txt</defaultSearchField>
<solrQueryParser defaultOperator="AND" />
This query worked before:
var q = solr.Query(Query.Field("id").Is(item.Id.ToString()) && Query.Field("searchobjecttype").Is(item.SearchObjectType));
solr.Delete(q);
solr.Commit();
While it won't work now.
When debugging, I can see that the query matches documents (the NumFound property returns more than 0 when the query finds items). However nothing is deleted.
When I try to delete the same document through Solr's web interface, it works.
What am I missing? :)
Cheers and thanks.

Try changing the guid field to string type (you'll have to reindex). The text field type probably does some analysis and you don't want to analyze this kind of data, you want to index it verbatim.

Related

Adding App to "Choose A Default Browser" via Wix Setup Project

I have an application that I'm trying to get to show up in "Choose A Default Browser" after installation on Windows 8.1 and 10. I followed another link, and was able to setup the following registry keys via the Wix Setup Project. All the keys are created on install, however, the application doesn't show up in the web browser list. Anyone know what I'm missing?
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="8b810d67-345d-4652-bf17-a503d120cccc">
<RegistryKey Root="HKLM"
Key="Software\MyApp"
Action="createAndRemoveOnUninstall">
<RegistryKey Key="Capabilities"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="ApplicationName" Value="MyApp"/>
<RegistryValue Type="string" Name="ApplicationIcon" Value="C:\Program Files (x86)\MyApp\MyApp.exe,0"/>
<RegistryValue Type="string" Name="ApplicationDescription" Value="A safe browsing experience."/>
<RegistryKey Key="FileAssociations"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name=".htm" Value="MyApp"/>
<RegistryValue Type="string" Name=".html" Value="MyApp"/>
<RegistryValue Type="string" Name=".shtml" Value="MyApp"/>
<RegistryValue Type="string" Name=".xht" Value="MyApp"/>
<RegistryValue Type="string" Name=".xhtml" Value="MyApp"/>
</RegistryKey>
<RegistryKey Key="URLAssociations"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="http" Value="MyApp"/>
<RegistryValue Type="string" Name="https" Value="MyApp"/>
<RegistryValue Type="string" Name="ftp" Value="MyApp"/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
<RegistryKey Root="HKLM"
Key="SOFTWARE\RegisteredApplications"
Action="none">
<RegistryValue Type="string" Name="MyApp" Value="Software\MyApp\Capabilities"/>
</RegistryKey>
<RegistryKey Root="HKLM"
Key="Software\Classes\MyApp"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Value="MyApp Document"/>
<RegistryKey Key="shell"
Action="createAndRemoveOnUninstall">
<RegistryKey Key="open"
Action="createAndRemoveOnUninstall">
<RegistryKey Key="command"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="MyApp" Value=""C:\Program Files (x86)\MyApp\MyApp.exe" "%1""/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</Component>
</DirectoryRef>
If you spot a missing element, please let me know.
I figured it out, so I thought I'd go ahead and post the answer for ya'll. When creating the "command" key inside of "Software\Classes\MyApp\shell\open", I had to remove the "Name" of the registry value, so that my registry value would be written to the "(Default)" string.
<RegistryKey Key="command"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Value=""C:\Program Files
(x86)\MyApp\MyApp.exe" "%1""/>
So my final working code in the Product.wxs file to get all the keys created, and my application in the "Choose a Web Browser" section was:
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="8b810d67-345d-4652-bf17-a503d120cccc">
<RegistryKey Root="HKLM"
Key="Software\MyApp"
Action="createAndRemoveOnUninstall">
<RegistryKey Key="Capabilities"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="ApplicationName" Value="MyApp"/>
<RegistryValue Type="string" Name="ApplicationIcon" Value="C:\Program Files (x86)\MyApp\MyApp.exe,0"/>
<RegistryValue Type="string" Name="ApplicationDescription" Value="A safe browsing experience."/>
<RegistryKey Key="FileAssociations"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name=".htm" Value="MyApp"/>
<RegistryValue Type="string" Name=".html" Value="MyApp"/>
<RegistryValue Type="string" Name=".shtml" Value="MyApp"/>
<RegistryValue Type="string" Name=".xht" Value="MyApp"/>
<RegistryValue Type="string" Name=".xhtml" Value="MyApp"/>
</RegistryKey>
<RegistryKey Key="URLAssociations"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="http" Value="MyApp"/>
<RegistryValue Type="string" Name="https" Value="MyApp"/>
<RegistryValue Type="string" Name="ftp" Value="MyApp"/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
<RegistryKey Root="HKLM"
Key="SOFTWARE\RegisteredApplications"
Action="none">
<RegistryValue Type="string" Name="MyApp" Value="Software\MyApp\Capabilities"/>
</RegistryKey>
<RegistryKey Root="HKLM"
Key="Software\Classes\MyApp"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Value="MyApp Document"/>
<RegistryKey Key="shell"
Action="createAndRemoveOnUninstall">
<RegistryKey Key="open"
Action="createAndRemoveOnUninstall">
<RegistryKey Key="command"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Value=""C:\Program Files (x86)\MyApp\MyApp.exe" "%1""/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</Component>
</DirectoryRef>

Cannot check tables, views in update wizard when updating model from database at Visual Studio 2017

I have a Microsoft SQL Server database connected to an Entity Framework Web API project. I run SSMS & VS 2017.
I erased some column in the model and I want to re-create it with updating from the database. When I try updating model from DB option on the edmx file, there is an update wizard.
The update wizard doesn't allow me to check and table or view in the wizard. It also doesn't add the column from the database to model.
I also have errors as follows (that maybe will disappear when the column will be added to the model):
Error 3023: Problem in mapping fragments starting at line 309:Column GamesScores.GameDateCreation in table GamesScores must be mapped: It has no default value and is not nullable.
01-Data Access Layer C:\projects\webApi\memory match game\Memory Match Game\01-Data Access Layer\MemoryMatch.edmx 310
Error CS0006 Metadata file 'C:\projects\webApi\memory match game\Memory Match Game\03-Business Logic Layer\bin\Debug\03-Business Logic Layer.dll' could not be found
04- Web Api C:\projects\webApi\memory match game\Memory Match Game\04- Web
Api\CSC 1 Active
Here is the mapping of the tables
And here is the EDMX code in a HTML view:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="MemoryMatchModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
<EntityType Name="ContactMessages">
<Key>
<PropertyRef Name="MessageID" />
</Key>
<Property Name="MessageID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="MessageTimeStamp" Type="datetime" Nullable="false" />
<Property Name="Phone" Type="nvarchar" MaxLength="50" />
<Property Name="Email" Type="nvarchar" MaxLength="50" />
<Property Name="MessageText" Type="nvarchar" MaxLength="200" Nullable="false" />
</EntityType>
<EntityType Name="Feedbacks">
<Key>
<PropertyRef Name="FeedbackID" />
</Key>
<Property Name="FeedbackID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="UserID" Type="int" Nullable="false" />
<Property Name="FeedbackTimeStamp" Type="datetime" Nullable="false" />
<Property Name="FeedbackText" Type="nvarchar" MaxLength="250" Nullable="false" />
</EntityType>
<EntityType Name="GamesScores">
<Key>
<PropertyRef Name="GameScoreID" />
</Key>
<Property Name="GameScoreID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="UserID" Type="int" Nullable="false" />
<Property Name="GameDateCreation" Type="datetime" Nullable="false" />
<Property Name="GameDuration" Type="time" Precision="7" Nullable="false" />
<Property Name="GameSteps" Type="int" Nullable="false" />
</EntityType>
<EntityType Name="Images">
<Key>
<PropertyRef Name="ImageID" />
</Key>
<Property Name="ImageID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="ImageName" Type="nvarchar" MaxLength="256" Nullable="false" />
</EntityType>
<EntityType Name="sysdiagrams">
<Key>
<PropertyRef Name="diagram_id" />
</Key>
<Property Name="name" Type="nvarchar" MaxLength="128" Nullable="false" />
<Property Name="principal_id" Type="int" Nullable="false" />
<Property Name="diagram_id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="version" Type="int" />
<Property Name="definition" Type="varbinary(max)" />
</EntityType>
<EntityType Name="Users">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="FullName" Type="nvarchar" MaxLength="50" Nullable="false" />
<Property Name="UserName" Type="nvarchar" MaxLength="50" Nullable="false" />
<Property Name="Password" Type="nvarchar" MaxLength="50" Nullable="false" />
<Property Name="Email" Type="nvarchar" MaxLength="50" />
<Property Name="Birthdate" Type="date" />
</EntityType>
<Association Name="FK_Feedbacks_Users">
<End Role="Users" Type="Self.Users" Multiplicity="1" />
<End Role="Feedbacks" Type="Self.Feedbacks" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Users">
<PropertyRef Name="UserID" />
</Principal>
<Dependent Role="Feedbacks">
<PropertyRef Name="UserID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_GamesScores_Users">
<End Role="Users" Type="Self.Users" Multiplicity="1" />
<End Role="GamesScores" Type="Self.GamesScores" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Users">
<PropertyRef Name="UserID" />
</Principal>
<Dependent Role="GamesScores">
<PropertyRef Name="UserID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Function Name="fn_diagramobjects" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" ReturnType="int" />
<Function Name="sp_alterdiagram" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="diagramname" Type="nvarchar" Mode="In" />
<Parameter Name="owner_id" Type="int" Mode="In" />
<Parameter Name="version" Type="int" Mode="In" />
<Parameter Name="definition" Type="varbinary(max)" Mode="In" />
</Function>
<Function Name="sp_creatediagram" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="diagramname" Type="nvarchar" Mode="In" />
<Parameter Name="owner_id" Type="int" Mode="In" />
<Parameter Name="version" Type="int" Mode="In" />
<Parameter Name="definition" Type="varbinary(max)" Mode="In" />
</Function>
<Function Name="sp_dropdiagram" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="diagramname" Type="nvarchar" Mode="In" />
<Parameter Name="owner_id" Type="int" Mode="In" />
</Function>
<Function Name="sp_helpdiagramdefinition" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="diagramname" Type="nvarchar" Mode="In" />
<Parameter Name="owner_id" Type="int" Mode="In" />
</Function>
<Function Name="sp_helpdiagrams" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="diagramname" Type="nvarchar" Mode="In" />
<Parameter Name="owner_id" Type="int" Mode="In" />
</Function>
<Function Name="sp_renamediagram" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="diagramname" Type="nvarchar" Mode="In" />
<Parameter Name="owner_id" Type="int" Mode="In" />
<Parameter Name="new_diagramname" Type="nvarchar" Mode="In" />
</Function>
<Function Name="sp_upgraddiagrams" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo" />
<EntityContainer Name="MemoryMatchModelStoreContainer">
<EntitySet Name="ContactMessages" EntityType="Self.ContactMessages" Schema="dbo" store:Type="Tables" />
<EntitySet Name="Feedbacks" EntityType="Self.Feedbacks" Schema="dbo" store:Type="Tables" />
<EntitySet Name="GamesScores" EntityType="Self.GamesScores" Schema="dbo" store:Type="Tables" />
<EntitySet Name="Images" EntityType="Self.Images" Schema="dbo" store:Type="Tables" />
<EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
<EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
<AssociationSet Name="FK_Feedbacks_Users" Association="Self.FK_Feedbacks_Users">
<End Role="Users" EntitySet="Users" />
<End Role="Feedbacks" EntitySet="Feedbacks" />
</AssociationSet>
<AssociationSet Name="FK_GamesScores_Users" Association="Self.FK_GamesScores_Users">
<End Role="Users" EntitySet="Users" />
<End Role="GamesScores" EntitySet="GamesScores" />
</AssociationSet>
</EntityContainer>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="MemoryMatchModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="ContactMessage">
<Key>
<PropertyRef Name="MessageID" />
</Key>
<Property Name="MessageID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="MessageTimeStamp" Type="DateTime" Nullable="false" Precision="3" />
<Property Name="Phone" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Email" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="MessageText" Type="String" MaxLength="200" FixedLength="false" Unicode="true" Nullable="false" />
</EntityType>
<EntityType Name="Feedback">
<Key>
<PropertyRef Name="FeedbackID" />
</Key>
<Property Name="FeedbackID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="UserID" Type="Int32" Nullable="false" />
<Property Name="FeedbackTimeStamp" Type="DateTime" Nullable="false" Precision="3" />
<Property Name="FeedbackText" Type="String" MaxLength="250" FixedLength="false" Unicode="true" Nullable="false" />
<NavigationProperty Name="User" Relationship="Self.FK_Feedbacks_Users" FromRole="Feedbacks" ToRole="Users" />
</EntityType>
<EntityType Name="GamesScore">
<Key>
<PropertyRef Name="GameScoreID" />
</Key>
<Property Name="GameScoreID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="UserID" Type="Int32" Nullable="false" />
<Property Name="GameSteps" Type="Int32" Nullable="false" />
<NavigationProperty Name="User" Relationship="Self.FK_GamesScores_Users" FromRole="GamesScores" ToRole="Users" />
<Property Name="GameDuration" Type="Time" Nullable="false" Precision="7" />
</EntityType>
<EntityType Name="Image">
<Key>
<PropertyRef Name="ImageID" />
</Key>
<Property Name="ImageID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="ImageName" Type="String" MaxLength="256" FixedLength="false" Unicode="true" Nullable="false" />
</EntityType>
<EntityType Name="sysdiagram">
<Key>
<PropertyRef Name="diagram_id" />
</Key>
<Property Name="name" Type="String" MaxLength="128" FixedLength="false" Unicode="true" Nullable="false" />
<Property Name="principal_id" Type="Int32" Nullable="false" />
<Property Name="diagram_id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="version" Type="Int32" />
<Property Name="definition" Type="Binary" MaxLength="Max" FixedLength="false" />
</EntityType>
<EntityType Name="User">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="FullName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
<Property Name="UserName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
<Property Name="Password" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
<Property Name="Email" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Birthdate" Type="DateTime" Precision="0" />
<NavigationProperty Name="Feedbacks" Relationship="Self.FK_Feedbacks_Users" FromRole="Users" ToRole="Feedbacks" />
<NavigationProperty Name="GamesScores" Relationship="Self.FK_GamesScores_Users" FromRole="Users" ToRole="GamesScores" />
</EntityType>
<Association Name="FK_Feedbacks_Users">
<End Role="Users" Type="Self.User" Multiplicity="1" />
<End Role="Feedbacks" Type="Self.Feedback" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Users">
<PropertyRef Name="UserID" />
</Principal>
<Dependent Role="Feedbacks">
<PropertyRef Name="UserID" />
</Dependent>
</ReferentialConstraint>
</Association>
<Association Name="FK_GamesScores_Users">
<End Role="Users" Type="Self.User" Multiplicity="1" />
<End Role="GamesScores" Type="Self.GamesScore" Multiplicity="*" />
<ReferentialConstraint>
<Principal Role="Users">
<PropertyRef Name="UserID" />
</Principal>
<Dependent Role="GamesScores">
<PropertyRef Name="UserID" />
</Dependent>
</ReferentialConstraint>
</Association>
<EntityContainer Name="MemoryMatchEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="ContactMessages" EntityType="Self.ContactMessage" />
<EntitySet Name="Feedbacks" EntityType="Self.Feedback" />
<EntitySet Name="GamesScores" EntityType="Self.GamesScore" />
<EntitySet Name="Images" EntityType="Self.Image" />
<EntitySet Name="sysdiagrams" EntityType="Self.sysdiagram" />
<EntitySet Name="Users" EntityType="Self.User" />
<AssociationSet Name="FK_Feedbacks_Users" Association="Self.FK_Feedbacks_Users">
<End Role="Users" EntitySet="Users" />
<End Role="Feedbacks" EntitySet="Feedbacks" />
</AssociationSet>
<AssociationSet Name="FK_GamesScores_Users" Association="Self.FK_GamesScores_Users">
<End Role="Users" EntitySet="Users" />
<End Role="GamesScores" EntitySet="GamesScores" />
</AssociationSet>
<FunctionImport Name="sp_alterdiagram">
<Parameter Name="diagramname" Mode="In" Type="String" />
<Parameter Name="owner_id" Mode="In" Type="Int32" />
<Parameter Name="version" Mode="In" Type="Int32" />
<Parameter Name="definition" Mode="In" Type="Binary" />
</FunctionImport>
<FunctionImport Name="sp_creatediagram">
<Parameter Name="diagramname" Mode="In" Type="String" />
<Parameter Name="owner_id" Mode="In" Type="Int32" />
<Parameter Name="version" Mode="In" Type="Int32" />
<Parameter Name="definition" Mode="In" Type="Binary" />
</FunctionImport>
<FunctionImport Name="sp_dropdiagram">
<Parameter Name="diagramname" Mode="In" Type="String" />
<Parameter Name="owner_id" Mode="In" Type="Int32" />
</FunctionImport>
<FunctionImport Name="sp_helpdiagramdefinition" ReturnType="Collection(MemoryMatchModel.sp_helpdiagramdefinition_Result)">
<Parameter Name="diagramname" Mode="In" Type="String" />
<Parameter Name="owner_id" Mode="In" Type="Int32" />
</FunctionImport>
<FunctionImport Name="sp_helpdiagrams" ReturnType="Collection(MemoryMatchModel.sp_helpdiagrams_Result)">
<Parameter Name="diagramname" Mode="In" Type="String" />
<Parameter Name="owner_id" Mode="In" Type="Int32" />
</FunctionImport>
<FunctionImport Name="sp_renamediagram">
<Parameter Name="diagramname" Mode="In" Type="String" />
<Parameter Name="owner_id" Mode="In" Type="Int32" />
<Parameter Name="new_diagramname" Mode="In" Type="String" />
</FunctionImport>
<FunctionImport Name="sp_upgraddiagrams" />
</EntityContainer>
<ComplexType Name="sp_helpdiagramdefinition_Result">
<Property Type="Int32" Name="version" Nullable="true" />
<Property Type="Binary" Name="definition" Nullable="true" />
</ComplexType>
<ComplexType Name="sp_helpdiagrams_Result">
<Property Type="String" Name="Database" Nullable="true" MaxLength="128" />
<Property Type="String" Name="Name" Nullable="false" MaxLength="128" />
<Property Type="Int32" Name="ID" Nullable="false" />
<Property Type="String" Name="Owner" Nullable="true" MaxLength="128" />
<Property Type="Int32" Name="OwnerID" Nullable="false" />
</ComplexType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping StorageEntityContainer="MemoryMatchModelStoreContainer" CdmEntityContainer="MemoryMatchEntities">
<EntitySetMapping Name="ContactMessages">
<EntityTypeMapping TypeName="MemoryMatchModel.ContactMessage">
<MappingFragment StoreEntitySet="ContactMessages">
<ScalarProperty Name="MessageID" ColumnName="MessageID" />
<ScalarProperty Name="MessageTimeStamp" ColumnName="MessageTimeStamp" />
<ScalarProperty Name="Phone" ColumnName="Phone" />
<ScalarProperty Name="Email" ColumnName="Email" />
<ScalarProperty Name="MessageText" ColumnName="MessageText" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Feedbacks">
<EntityTypeMapping TypeName="MemoryMatchModel.Feedback">
<MappingFragment StoreEntitySet="Feedbacks">
<ScalarProperty Name="FeedbackID" ColumnName="FeedbackID" />
<ScalarProperty Name="UserID" ColumnName="UserID" />
<ScalarProperty Name="FeedbackTimeStamp" ColumnName="FeedbackTimeStamp" />
<ScalarProperty Name="FeedbackText" ColumnName="FeedbackText" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="GamesScores">
<EntityTypeMapping TypeName="MemoryMatchModel.GamesScore">
<MappingFragment StoreEntitySet="GamesScores">
<ScalarProperty Name="GameDuration" ColumnName="GameDuration" />
<ScalarProperty Name="GameScoreID" ColumnName="GameScoreID" />
<ScalarProperty Name="UserID" ColumnName="UserID" />
<ScalarProperty Name="GameSteps" ColumnName="GameSteps" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Images">
<EntityTypeMapping TypeName="MemoryMatchModel.Image">
<MappingFragment StoreEntitySet="Images">
<ScalarProperty Name="ImageID" ColumnName="ImageID" />
<ScalarProperty Name="ImageName" ColumnName="ImageName" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="sysdiagrams">
<EntityTypeMapping TypeName="MemoryMatchModel.sysdiagram">
<MappingFragment StoreEntitySet="sysdiagrams">
<ScalarProperty Name="name" ColumnName="name" />
<ScalarProperty Name="principal_id" ColumnName="principal_id" />
<ScalarProperty Name="diagram_id" ColumnName="diagram_id" />
<ScalarProperty Name="version" ColumnName="version" />
<ScalarProperty Name="definition" ColumnName="definition" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Users">
<EntityTypeMapping TypeName="MemoryMatchModel.User">
<MappingFragment StoreEntitySet="Users">
<ScalarProperty Name="UserID" ColumnName="UserID" />
<ScalarProperty Name="FullName" ColumnName="FullName" />
<ScalarProperty Name="UserName" ColumnName="UserName" />
<ScalarProperty Name="Password" ColumnName="Password" />
<ScalarProperty Name="Email" ColumnName="Email" />
<ScalarProperty Name="Birthdate" ColumnName="Birthdate" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<FunctionImportMapping FunctionImportName="sp_alterdiagram" FunctionName="MemoryMatchModel.Store.sp_alterdiagram" />
<FunctionImportMapping FunctionImportName="sp_creatediagram" FunctionName="MemoryMatchModel.Store.sp_creatediagram" />
<FunctionImportMapping FunctionImportName="sp_dropdiagram" FunctionName="MemoryMatchModel.Store.sp_dropdiagram" />
<FunctionImportMapping FunctionImportName="sp_helpdiagramdefinition" FunctionName="MemoryMatchModel.Store.sp_helpdiagramdefinition">
<ResultMapping>
<ComplexTypeMapping TypeName="MemoryMatchModel.sp_helpdiagramdefinition_Result">
<ScalarProperty Name="version" ColumnName="version" />
<ScalarProperty Name="definition" ColumnName="definition" />
</ComplexTypeMapping>
</ResultMapping>
</FunctionImportMapping>
<FunctionImportMapping FunctionImportName="sp_helpdiagrams" FunctionName="MemoryMatchModel.Store.sp_helpdiagrams">
<ResultMapping>
<ComplexTypeMapping TypeName="MemoryMatchModel.sp_helpdiagrams_Result">
<ScalarProperty Name="Database" ColumnName="Database" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="ID" ColumnName="ID" />
<ScalarProperty Name="Owner" ColumnName="Owner" />
<ScalarProperty Name="OwnerID" ColumnName="OwnerID" />
</ComplexTypeMapping>
</ResultMapping>
</FunctionImportMapping>
<FunctionImportMapping FunctionImportName="sp_renamediagram" FunctionName="MemoryMatchModel.Store.sp_renamediagram" />
<FunctionImportMapping FunctionImportName="sp_upgraddiagrams" FunctionName="MemoryMatchModel.Store.sp_upgraddiagrams" />
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="true" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
<DesignerProperty Name="UseLegacyProvider" Value="false" />
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams></Diagrams>
</Designer>
</edmx:Edmx>
Why can't I add the column GameDateCreation to my model from the database?
Is it because of the errors I mentioned?
You have mentioned column GameDateCreation under <EntityType Name="GamesScores"> in section SSDL. But, You have not mentioned same column GameDateCreation mentioned under <EntitySetMapping Name="GamesScores"> in Mappings section.
There should be below mentioned line code under <EntitySetMapping Name="GamesScores">.
<ScalarProperty Name="GameDateCreation" ColumnName="GameDateCreation" />
Other workaround will be remove all references of column GameDateCreation from edmx file and try to add column to model from database.
Please let me know how you go.

Checkbox not showing at custom datalist in Alfresco

I've been trying to help one of my colleagues with an issue with Alfresco custom datalists. We are using Alfresco Community 5.0.d
We have a custom datalist in which there is a checkbox in one of the fields.
The code in both sides looks the same to us... The file checkbox.ftl is inside the same place in both places, and it is exactly the same file. We have also rebuilt the indices just in case which as far as I have understood it won't be necessary in this case. All the datalist works correctly except the checkbox. We have seen that the 'input type="checkbox"' is not in the view generated at the production side. We have no clue where to look. I'm about to copy all the modified/added file for this matter. If you need any extra information just tell me and I will gladly provide it.
In the test environment, we have managed to make it work using the following code:
<model name="datos:datosModel"
xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Custom Datalist</description>
<author>Maria Royo</author>
<version>1.0</version>
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<!--Import Alfresco Data List Model Definitions -->
<import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
</imports>
<!-- Introduction of new namespaces defined by this model -->
<!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace -->
<namespaces>
<namespace uri="datos.datosModel" prefix="datos"/>
</namespaces>
<!-- Tipo de dato combobox -->
<!-- Scope-->
<constraints>
<constraint name="datos:Scope" type="LIST">
<parameter name="allowedValues">
<list>
<value>ESA</value>
<value>IOT</value>
<value>Internal</value>
</list>
</parameter>
</constraint>
</constraints>
<types>
<!-- Data list defintions For this model go here -->
<type name="datos:datosTabla">
<title>Document Library</title>
<description>Document Library del EMIS</description>
<parent>dl:dataListItem</parent>
<properties>
<property name="datos:datosID">
<title>Reference</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosTitle">
<title>Title</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosVersions">
<title>Versions</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosIncr">
<title>Increment</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosUpdate">
<title>Last Update</title>
<type>d:date</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosDRD">
<title>DRD Reference</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosScope">
<title>Scope</title>
<type>d:text</type>
<mandatory>false</mandatory>
<constraints>
<constraint ref="datos:Scope" />
</constraints>
</property>
<property name="datos:datosRemarks">
<title>Remarks</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<!-- Type Checkbox -->
<property name="datos:datosDel">
<title>Delivered</title>
<description>Active</description>
<type>d:boolean</type>
</property>
</properties>
<associations>
<association name="datos:datosAttachments">
<title>Link</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:cmobject</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
</types>
This is the code we have at the production environment:
<model name="datos:datosModel"
xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Custom Datalist</description>
<author>Maria Royo</author>
<version>1.0</version>
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<!--Import Alfresco Data List Model Definitions -->
<import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl"/>
</imports>
<!-- Introduction of new namespaces defined by this model -->
<!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace -->
<namespaces>
<namespace uri="datos.datosModel" prefix="datos"/>
</namespaces>
<!-- Tipo de dato combobox -->
<!-- Scope-->
<constraints>
<constraint name="datos:Scope" type="LIST">
<parameter name="allowedValues">
<list>
<value>ESA</value>
<value>IOT</value>
<value>Internal</value>
</list>
</parameter>
</constraint>
</constraints>
<types>
<!-- Data list defintions For this model go here -->
<type name="datos:datosTabla">
<title>E-USOC Document Library</title>
<description>E-USOC Document Library</description>
<parent>dl:dataListItem</parent>
<properties>
<property name="datos:datosID">
<title>Reference</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosTitle">
<title>Title</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosVersions">
<title>Versions</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosIncr">
<title>Increment</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosUpdate">
<title>Last Update</title>
<type>d:date</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosDRD">
<title>DRD Reference</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="datos:datosScope">
<title>Scope</title>
<type>d:text</type>
<mandatory>false</mandatory>
<constraints>
<constraint ref="datos:Scope" />
</constraints>
</property>
<property name="datos:datosRemarks">
<title>Remarks</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<!-- Type Checkbox -->
<property name="datos:datosDel">
<title>Delivered</title>
<description>Delivered</description>
<type>d:boolean</type>
</property>
</properties>
<associations>
<association name="datos:datosAttachments">
<title>Link</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:cmobject</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
</types>
Both files are inside the same directory which is:
/alfresco-5.0.d/tomcat/shared/classes/alfresco/extension
Also, we have this code inside the:
/alfresco-5.0.d/tomcat/shared/classes/alfresco/web-extension/share_config_custom.xml
At test environment the code is as follow:
<config evaluator="model-type" condition="datos:datosTabla">
<forms>
<!-- Create item form -->
<form>
<field-visibility>
<show id="datos:datosID" />
<show id="datos:datosTitle" />
<show id="datos:datosAttachments" />
<show id="datos:datosVersions" />
<show id="datos:datosIncr" />
<show id="datos:datosUpdate" />
<show id="datos:datosDRD" />
<show id="datos:datosScope" />
<show id="datos:datosDel" />
<show id="datos:datosRemarks" />
</field-visibility>
<create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
<appearance>
<field id="datos:datosID">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosTitle">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosAttachments">
<control>
<control-param name="startLocation">{doclib}</control-param>
</control>
</field>
<field id="datos:datosVersions">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosIncr">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosUpdates">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosDRD">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosScope">
<control template="/org/alfresco/components/form/controls/selectone.ftl" />
</field>
<field id="datos:datosDel">
<control template="/org/alfresco/components/form/controls/checkbox.ftl" />
</field>
<field id="datos:datosRemarks">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
<!--Data Grid view-->
<form id="datagrid">
<field-visibility>
<show id="datos:datosID" />
<show id="datos:datosTitle" />
<show id="datos:datosAttachments" />
<show id="datos:datosVersions" />
<show id="datos:datosIncr" />
<show id="datos:datosUpdate" />
<show id="datos:datosDRD" />
<show id="datos:datosScope" />
<show id="datos:datosDel" />
<show id="datos:datosRemarks" />
</field-visibility>
</form>
</forms>
</config>
<!-- Edit view -->
<config evaluator="node-type" condition="datos:datosTabla">
<forms>
Edit marketing item form
<form>
<field-visibility>
<show id="datos:datosID" />
<show id="datos:datosTitle" />
<show id="datos:datosAttachments" />
<show id="datos:datosVersions" />
<show id="datos:datosIncr" />
<show id="datos:datosUpdate" />
<show id="datos:datosDRD" />
<show id="datos:datosScope" />
<show id="datos:datosDel" />
<show id="datos:datosRemarks" />
</field-visibility>
<create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
<appearance>
<field id="datos:datosID">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosTitle">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosAttachments">
<control>
<control-param name="startLocation">{doclib}</control-param>
</control>
</field>
<field id="datos:datosVersions">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosIncr">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosUpdates">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosDRD">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosScope">
<control template="/org/alfresco/components/form/controls/selectone.ftl" />
</field>
<field id="datos:datosDel">
<control template="/org/alfresco/components/form/controls/checkbox.ftl" />
</field>
<field id="datos:datosRemarks">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
And finally the code in the production environment:
<config evaluator="model-type" condition="datos:datosTabla">
<forms>
<!-- Create item form -->
<form>
<field-visibility>
<show id="datos:datosID" />
<show id="datos:datosTitle" />
<show id="datos:datosAttachments" />
<show id="datos:datosVersions" />
<show id="datos:datosIncr" />
<show id="datos:datosUpdate" />
<show id="datos:datosDRD" />
<show id="datos:datosScope" />
<show id="datos:datosDel" />
<show id="datos:datosRemarks" />
</field-visibility>
<create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
<appearance>
<field id="datos:datosID">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosTitle">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosAttachments">
<control>
<control-param name="startLocation">{doclib}</control-param>
</control>
</field>
<field id="datos:datosVersions">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosIncr">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosUpdates">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosDRD">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosScope">
<control template="/org/alfresco/components/form/controls/selectone.ftl" />
</field>
<field id="datos:datosDel">
<control template="/org/alfresco/components/form/controls/checkbox.ftl" />
</field>
<field id="datos:datosRemarks">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
<!--Data Grid view-->
<form id="datagrid">
<field-visibility>
<show id="datos:datosID" />
<show id="datos:datosTitle" />
<show id="datos:datosAttachments" />
<show id="datos:datosVersions" />
<show id="datos:datosIncr" />
<show id="datos:datosUpdate" />
<show id="datos:datosDRD" />
<show id="datos:datosScope" />
<show id="datos:datosDel" />
<show id="datos:datosRemarks" />
</field-visibility>
</form>
</forms>
</config>
<!-- Edit view -->
<config evaluator="node-type" condition="datos:datosTabla">
<forms>
<!-- Edit marketing item form -->
<form>
<field-visibility>
<show id="datos:datosID" />
<show id="datos:datosTitle" />
<show id="datos:datosAttachments" />
<show id="datos:datosVersions" />
<show id="datos:datosIncr" />
<show id="datos:datosUpdate" />
<show id="datos:datosDRD" />
<show id="datos:datosScope" />
<show id="datos:datosDel" />
<show id="datos:datosRemarks" />
</field-visibility>
<create-form template="/org/alfresco/components/data-lists/forms/dataitem.ftl" />
<appearance>
<field id="datos:datosID">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosTitle">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosAttachments">
<control>
<control-param name="startLocation">{doclib}</control-param>
</control>
</field>
<field id="datos:datosVersions">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosIncr">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosUpdates">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosDRD">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
<field id="datos:datosScope">
<control template="/org/alfresco/components/form/controls/selectone.ftl" />
</field>
<field id="datos:datosDel">
<control template="/org/alfresco/components/form/controls/checkbox.ftl" />
</field>
<field id="datos:datosRemarks">
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</field>
</appearance>
</form>
</forms>
</config>

Bulk inserting data with XML format file in MS SQL?

I am pretty new to databases (normally stored everything locally on CSV or HDFS files). I have access to MS SQL Server and I have been trying to load some historical data into the database. I was successful finally and I want to redo my steps for other data, but first I want to make sure that I am being efficient.
1) I create a table using a query and specify the data type of each column and the number of characters (I used len() in Excel and then added a buffer just in case)
2) I then created an XML file, example is below. I notated the delimiter and the data type for each column along with things like max_length and precision/scale where needed.
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="7" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="10"/>
<FIELD ID="8" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="9" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="10" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="11" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="3"/>
<FIELD ID="12" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="3"/>
<FIELD ID="13" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="14" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="15" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="16" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="17" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="18" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="19" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="20" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="21" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="22" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="23" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="24" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="25" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="26" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="27" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="28" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="29" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="30" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="31" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="32" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="33" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="34" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="35" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="36" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="37" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="38" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="39" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="40" xsi:type="CharTerm" TERMINATOR=","/>
<FIELD ID="41" xsi:type="CharTerm" TERMINATOR="\r\n"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="date" xsi:type="SQLDATE"/>
<COLUMN SOURCE="2" NAME="time" xsi:type="SQLDATETIME"/>
<COLUMN SOURCE="3" NAME="other_date" xsi:type="SQLDATE"/>
<COLUMN SOURCE="4" NAME="other_time" xsi:type="SQLDATETIME"/>
<COLUMN SOURCE="5" NAME="client_id" xsi:type="SQLINT"/>
<COLUMN SOURCE="6" NAME="location_id" xsi:type="SQLSMALLINT"/>
<COLUMN SOURCE="7" NAME="other_id" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="8" NAME="stuff_1" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="9" NAME="stuff_2" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="10" NAME="email" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="11" NAME="something_active" xsi:type="SQLVARYCHAR"/>
<COLUMN SOURCE="12" NAME="something_active" xsi:type="SQLVARYCHAR"/>
<COLUMN SOURCE="13" NAME="etc" xsi:type="SQLSMALLINT"/>
<COLUMN SOURCE="14" NAME="etc2" xsi:type="SQLDECIMAL" PRECISION="18" SCALE="2"/>
<COLUMN SOURCE="15" NAME="filler" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="16" NAME="filler" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="17" NAME="fk1" xsi:type="SQLSMALLINT"/>
<COLUMN SOURCE="18" NAME="fk2" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="19" NAME="fk3" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="20" NAME="fk4" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="21" NAME="fk5" xsi:type="SQLSMALLINT"/>
<COLUMN SOURCE="22" NAME="fk6" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="23" NAME="fk7" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="24" NAME="data1" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="25" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="26" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="27" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="28" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="29" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="30" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="31" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="32" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="33" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="34" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="35" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="36" NAME="data" xsi:type="SQLDECIMAL" PRECISION="5" SCALE="2"/>
<COLUMN SOURCE="37" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="38" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="39" NAME="data" xsi:type="SQLTINYINT"/>
<COLUMN SOURCE="40" NAME="data" xsi:type="SQLDECIMAL" PRECISION="5" SCALE="0"/>
<COLUMN SOURCE="41" NAME="data" xsi:type="SQLTINYINT"/>
</ROW>
</BCPFORMAT>
This worked and it was pretty fast for a few million rows. My question now is whether I need to do this for each file I am going to import (each is probably around 1 million to about 20 million records)? It is somewhat tedious creating a separate CREATE TABLE query and XML file per file, but it should only be a one time thing. Just want to make sure that I am not missing out on a more efficient approach to this whole thing.

How to generate xml file as output for a database in specific format through stored procedure in SQL Server?

I want to generate an xml file in the format shown below through a stored procedure.
I am facing few issues to fetch the values in the same format for the foreign key tag which is below. So can anyone help me out on how to create a stored procedure which yields the result in below given format?
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<database name="Northwind" default="True">
<schema name="dbo" default="True">
<table name="Categories">
<field name="CategoryID" primary_key="True" type_name="int" type="Int32" size="4" precision="10" scale="255" nullable="False" readonly="True" />
<field name="CategoryName" type_name="nvarchar" type="String" size="15" precision="255" scale="255" nullable="False" />
<field name="Description" type_name="ntext" type="String" size="1073741823" precision="255" scale="255" />
<field name="Picture" type_name="image" type="Binary" size="2147483647" precision="255" scale="255" />
</table>
<table name="Customers">
<field name="CustomerID" primary_key="True" type_name="nchar" type="String" size="5" precision="255" scale="255" nullable="False" />
<field name="CompanyName" type_name="nvarchar" type="String" size="40" precision="255" scale="255" nullable="False" />
<field name="ContactName" type_name="nvarchar" type="String" size="30" precision="255" scale="255" />
<field name="ContactTitle" type_name="nvarchar" type="String" size="30" precision="255" scale="255" />
<field name="Address" type_name="nvarchar" type="String" size="60" precision="255" scale="255" />
<field name="City" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="Region" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="PostalCode" type_name="nvarchar" type="String" size="10" precision="255" scale="255" />
<field name="Country" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="Phone" type_name="nvarchar" type="String" size="24" precision="255" scale="255" />
<field name="Fax" type_name="nvarchar" type="String" size="24" precision="255" scale="255" />
</table>
<table name="Shippers">
<field name="ShipperID" primary_key="True" type_name="int" type="Int32" size="4" precision="10" scale="255" nullable="False" readonly="True" />
<field name="CompanyName" type_name="nvarchar" type="String" size="40" precision="255" scale="255" nullable="False" />
<field name="Phone" type_name="nvarchar" type="String" size="24" precision="255" scale="255" />
</table>
<table name="Suppliers">
<field name="SupplierID" primary_key="True" type_name="int" type="Int32" size="4" precision="10" scale="255" nullable="False" readonly="True" />
<field name="CompanyName" type_name="nvarchar" type="String" size="40" precision="255" scale="255" nullable="False" />
<field name="ContactName" type_name="nvarchar" type="String" size="30" precision="255" scale="255" />
<field name="ContactTitle" type_name="nvarchar" type="String" size="30" precision="255" scale="255" />
<field name="Address" type_name="nvarchar" type="String" size="60" precision="255" scale="255" />
<field name="City" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="Region" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="PostalCode" type_name="nvarchar" type="String" size="10" precision="255" scale="255" />
<field name="Country" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="Phone" type_name="nvarchar" type="String" size="24" precision="255" scale="255" />
<field name="Fax" type_name="nvarchar" type="String" size="24" precision="255" scale="255" />
<field name="HomePage" type_name="ntext" type="String" size="1073741823" precision="255" scale="255" />
</table>
<table name="Orders">
<field name="OrderID" primary_key="True" type_name="int" type="Int32" size="4" precision="10" scale="255" nullable="False" readonly="True" />
<field name="CustomerID" type_name="nchar" type="String" size="5" precision="255" scale="255" />
<field name="EmployeeID" type_name="int" type="Int32" size="4" precision="10" scale="255" />
<field name="OrderDate" type_name="datetime" type="DateTime" size="8" precision="23" scale="3" />
<field name="RequiredDate" type_name="datetime" type="DateTime" size="8" precision="23" scale="3" />
<field name="ShippedDate" type_name="datetime" type="DateTime" size="8" precision="23" scale="3" />
<field name="ShipVia" type_name="int" type="Int32" size="4" precision="10" scale="255" />
<field name="Freight" type_name="money" type="Decimal" size="8" precision="19" scale="255" />
<field name="ShipName" type_name="nvarchar" type="String" size="40" precision="255" scale="255" />
<field name="ShipAddress" type_name="nvarchar" type="String" size="60" precision="255" scale="255" />
<field name="ShipCity" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="ShipRegion" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<field name="ShipPostalCode" type_name="nvarchar" type="String" size="10" precision="255" scale="255" />
<field name="ShipCountry" type_name="nvarchar" type="String" size="15" precision="255" scale="255" />
<foreignkey>
<referenced_object>
<name>Customers</name>
<name>dbo</name>
<name>Northwind</name>
</referenced_object>
<referencing_field name="CustomerID" referenced_field="CustomerID" />
<referencing_cardinality>Many</referencing_cardinality>
<referenced_cardinality>One</referenced_cardinality>
</foreignkey>
<foreignkey>
<referenced_object>
<name>Shippers</name>
<name>dbo</name>
<name>Northwind</name>
</referenced_object>
<referencing_field name="ShipVia" referenced_field="ShipperID" />
<referencing_cardinality>Many</referencing_cardinality>
<referenced_cardinality>One</referenced_cardinality>
</foreignkey>
<foreignkey>
<referenced_object>
<name>Employees</name>
<name>dbo</name>
<name>Northwind</name>
</referenced_object>
<referencing_field name="EmployeeID" referenced_field="EmployeeID" />
<referencing_cardinality>Many</referencing_cardinality>
<referenced_cardinality>One</referenced_cardinality>
</foreignkey>
</table>
<table name="Products">
<field name="ProductID" primary_key="True" type_name="int" type="Int32" size="4" precision="10" scale="255" nullable="False" readonly="True" />
<field name="ProductName" type_name="nvarchar" type="String" size="40" precision="255" scale="255" nullable="False" />
<field name="SupplierID" type_name="int" type="Int32" size="4" precision="10" scale="255" />
<field name="CategoryID" type_name="int" type="Int32" size="4" precision="10" scale="255" />
<field name="QuantityPerUnit" type_name="nvarchar" type="String" size="20" precision="255" scale="255" />
<field name="UnitPrice" type_name="money" type="Decimal" size="8" precision="19" scale="255" />
<field name="UnitsInStock" type_name="smallint" type="Int16" size="2" precision="5" scale="255" />
<field name="UnitsOnOrder" type_name="smallint" type="Int16" size="2" precision="5" scale="255" />
<field name="ReorderLevel" type_name="smallint" type="Int16" size="2" precision="5" scale="255" />
<field name="Discontinued" type_name="bit" type="Boolean" size="1" precision="255" scale="255" nullable="False" />
<foreignkey>
<referenced_object>
<name>Categories</name>
<name>dbo</name>
<name>Northwind</name>
</referenced_object>
<referencing_field name="CategoryID" referenced_field="CategoryID" />
<referencing_cardinality>Many</referencing_cardinality>
<referenced_cardinality>One</referenced_cardinality>
</foreignkey>
<foreignkey>
<referenced_object>
<name>Suppliers</name>
<name>dbo</name>
<name>Northwind</name>
</referenced_object>
<referencing_field name="SupplierID" referenced_field="SupplierID" />
<referencing_cardinality>Many</referencing_cardinality>
<referenced_cardinality>One</referenced_cardinality>
</foreignkey>
</table>
</schema>
</database>
</metadata>
Declare #temp Table(result xml)
DECLARE #value varchar(50)
insert into #temp values((
Select DB_NAME() AS '#name',
(SELECT sc.SCHEMA_NAME as '#name' ,
(SELECT TABLE_NAME as '#name',
(
SELECT COLUMN_NAME as '#name',
t.name as '#type_name',
case DATA_TYPE
when 'nvarchar'
then 'String'
when 'varchar'
then 'String'
when 'int'
then 'Int32'
when 'bigint'
then 'Int64'
when 'bit'
then 'Boolean'
when 'datetime'
then 'DateTime'
else null
end as '#type',
NUMERIC_PRECISION as '#precision',
NUMERIC_SCALE as '#scale',
case data_type
when 'nvarchar'
then CHARACTER_MAXIMUM_LENGTH
when 'varchar'
then CHARACTER_MAXIMUM_LENGTH
else null
end as '#size',
INFORMATION_SCHEMA.COLUMNS.IS_NULLABLE AS '#nullable',
'true' as '#readonly',
'true'as '#primary_key'
FROM INFORMATION_SCHEMA.COLUMNS
INNER JOIN
sys.types t ON TYPE_ID(INFORMATION_SCHEMA.COLUMNS.DATA_TYPE) = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON t.name=INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
--ON ic.column_id = INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
where INFORMATION_SCHEMA.COLUMNS.TABLE_NAME =
INFORMATION_SCHEMA.TABLES.TABLE_NAME
order by INFORMATION_SCHEMA.COLUMNS.ORDINAL_POSITION
For XML PATH ('field'), type
)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='my schema'
ORDER BY TABLE_NAME ASC
For XML PATH ('table'),type)
from INFORMATION_SCHEMA.SCHEMATA sc where sc.SCHEMA_NAME IN(Select distinct TOP 1 ta.TABLE_SCHEMA from
INFORMATION_SCHEMA.TABLES ta )
For XML PATH('schema'),type)
For XML PATH('database'),Root('metadata')))
select * from #temp
The above code is used to generate just table data
The below stored procedure is used to generate the foreign key constraint
(select INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME as 'name',
INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_SCHEMA as 'name',
INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_CATALOG as 'name' ,
referencing_field_name =FK_COLS.COLUMN_NAME,
referenced_field = PK_COLS.COLUMN_NAME,
referencing_cardinality='Many',
referenced_cardinality='one'
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS REF_CONST
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS
ON REF_CONST.CONSTRAINT_CATALOG = INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_CATALOG
AND REF_CONST.CONSTRAINT_SCHEMA = INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_SCHEMA
AND REF_CONST.CONSTRAINT_NAME = INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME
AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'FOREIGN KEY'
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK
ON REF_CONST.UNIQUE_CONSTRAINT_CATALOG = PK.CONSTRAINT_CATALOG
AND REF_CONST.UNIQUE_CONSTRAINT_SCHEMA = PK.CONSTRAINT_SCHEMA
AND REF_CONST.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME
AND PK.CONSTRAINT_TYPE = 'PRIMARY KEY'
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE FK_COLS ON REF_CONST.CONSTRAINT_NAME = FK_COLS.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE PK_COLS ON PK.CONSTRAINT_NAME = PK_COLS.CONSTRAINT_NAME
FOR XML RAW ('referenced_object'), ELEMENTS, ROOT ('foreign key'))
We are facing an issue in integrating these two stored procedures
So, Is there any way to generate the xml file in the same format dynamically

Resources