如何在项目级

时间:2016-09-08 12:55:50

标签: codefluent

我已将项目级别的“默认持久性强制执行”属性设置为 true 。然后我在User和association之间设置了一个“Default persistence enforce”与 false 的关系。当我从一个关系导航到另一个关系时,我的属性仍然设置为 false

现在,当我运行生产者时:

  • 我的财产恢复为真

  • 生成的代码显示了CHECK CONSTRAINT,而不是NO CHECK

  • 数据透视中生成的约束显示为check="true"

是否可以在项目级别将“默认持久性强制执行”属性强制为true并停用某些关系?

感谢您的回答,

在模型部分下面

<cf:project defaultNamespace="WcfServices.Model" 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:cfsps="http://www.softfluent.com/codefluent/producers.sqlpivotscript/2013/1" defaultPersistenceEnforce="true" createDefaultMethodForms="true" createDefaultApplication="false" createDefaultHints="false">
  <cf:import path="Default.Surface.cfp" />
  <cf:entity name="Association" namespace="Example.Model.Association" categoryPath="/WcfServices.Model">
    <cf:property name="AssociationId" key="true" persistenceEnforce="true" />
    <cf:property name="Label" persistenceEnforce="true" />
    <cf:property name="Users" typeName="Example.Model.Association.UserCollection" relationPropertyName="Association" />
  </cf:entity>
  <cf:producer name="SQL Server" typeName="CodeFluent.Producers.SqlServer.SqlServerProducer, CodeFluent.Producers.SqlServer">
    <cf:configuration produceViews="true" targetDirectory="..\WcfServices.persistence" cfx:targetProject="..\WcfServices.persistence\WcfServices.persistence.sqlproj" cfx:targetProjectLayout="Update, DontRemove" />
  </cf:producer>
  <cf:producer name="Business Object Model (BOM)" typeName="CodeFluent.Producers.CodeDom.CodeDomProducer, CodeFluent.Producers.CodeDom">
    <cf:configuration compileWithVisualStudio="true" compile="false" codeDomProviderTypeName="CSharp" targetDirectory="..\WcfServices.model" cfx:targetProject="..\WcfServices.model\WcfServices.model.csproj" cfx:targetProjectLayout="Update">
      <subProducer typeName="Ixcys.Producers.ServiceModelProducer.ServiceProducer, Ixcys.Producers.ServiceModelProducer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" compileWithVisualStudio="true" compile="false" codeDomProviderTypeName="CSharp" targetDirectory="..\WcfServices.proxy" silverlightTargetVersion="Unspecified" jsonOptions="EnableJson" cfx:targetProject="..\WcfServices.web\WcfServices.web.csproj" cfx:targetProjectLayout="Update" />
    </cf:configuration>
  </cf:producer>
  <cf:entity name="User" namespace="Example.Model.Association" categoryPath="/WcfServices.Model">
    <cf:property name="UserId" key="true" persistenceEnforce="true" />
    <cf:property name="Name" persistenceEnforce="true" />
    <cf:property name="Association" typeName="Example.Model.Association.Association" relationPropertyName="Users" />
    <cf:property name="Adresses" typeName="Example.Model.Association.AddressCollection" relationPropertyName="User" persistenceEnforce="true" />
  </cf:entity>
  <cf:producer name="SQL Server Pivot Script" typeName="CodeFluent.Producers.SqlServer.SqlPivotScriptProducer, CodeFluent.Producers.SqlServer">
    <cf:configuration targetDirectory="..\WcfServices.web" cfx:targetProject="..\WcfServices.web\WcfServices.web.csproj" cfx:targetProjectLayout="Update" />
  </cf:producer>
  <cf:entity name="Address" namespace="Example.Model.Association" categoryPath="/WcfServices.Model">
    <cf:property name="AddressId" key="true" persistenceEnforce="true" />
    <cf:property name="Line" persistenceEnforce="true" />
    <cf:property name="User" typeName="Example.Model.Association.User" relationPropertyName="Adresses" persistenceEnforce="true" />
  </cf:entity>
</cf:project>

生成的SQL在下面给出

ALTER TABLE [dbo].[User] ADD CONSTRAINT [FK_Use_Us__Ass_Ass] FOREIGN KEY (
 [User_Association_AssociationId]
) REFERENCES [dbo].[Association](

 [Association_AssociationId]
)

0 个答案:

没有答案