0

我已将项目级别的属性“默认持久性强制”设置为true。然后我在用户和关联之间将“默认持久性强制”的关系设置为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]
)
4

0 回答 0