Ticket T708164
Visible to All Users

Map persistent classes to a schema other than the default "dbo"

created 6 years ago

[DevExpress Support Team: CLONED FROM Q439032: How do I map persistent classes to another schema, e.g. other than the default "dbo" in MS SQL Server?]
Hello,

I tried both options to map my persistent classes to a non-default schema as attached. But, when I login the system, it still go to select dbo.PermissionPolicyUser. Do I missing something?

Thanks,
Gary

Show previous comments (1)

    Hello Michael,

    Attached please find my sample project. I just follow the instruction in Q439032 to update WebApplication.cs.

    Maybe I need more coding? Could you please point me to the right direction?

    Thank you very much!

    Best Regards,
    Gary

    DevExpress Support Team 6 years ago

      Hi Gary,

      Thank you for your project. I reproduced the issue using it. I see that our Security System creates an MSSqlConnectionProvider instance for which the DataStoreCreated event is not raised. We will check if this is expected behavior.

      At the moment, I suggest you specify the data table scheme by using the Persistent attribute. You can assign it in the CustomizeTypesInfo method as described in the How to separate database tables from built-in system tables via a prefix or custom schema article. The code will be as follows:

      C#
      public override void CustomizeTypesInfo(ITypesInfo typesInfo) { base.CustomizeTypesInfo(typesInfo); CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo); XPDictionary dictionary = XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary; dictionary.GetClassInfo(typeof(DevExpress.ExpressApp.Xpo.Updating.ModuleInfo)); dictionary.GetClassInfo(typeof(DevExpress.Xpo.XPObjectType)); dictionary.GetClassInfo(typeof(DevExpress.Xpo.XPWeakReference)); foreach (XPClassInfo ci in dictionary.Classes) { if (ci.IsPersistent) { ci.RemoveAttribute(typeof(PersistentAttribute)); ci.AddAttribute(new PersistentAttribute(string.Format("xaf.{0}", ci.TableName))); typesInfo.RefreshInfo(ci.ClassType); } } }

        Hi Gosha,

        Yes, it works. This is the best option, right?! or Would there any trouble during version upgrade, etc ?

        Many Thanks,
        Gary

        Answers approved by DevExpress Support

        created 6 years ago (modified 6 years ago)

        Hi Gary,

        Thank you for your patience. The solution from the How do I map persistent classes to another schema, e.g. other than the default "dbo" in MS SQL Server? ticket implies that the connection pooling is disabled. In your sample, it's enabled. To resolve the issue, change

        C#
        dataStoreProvider = XPObjectSpaceProvider.GetDataStoreProvider(connectionString, connection, true);

        to

        C#
        dataStoreProvider = XPObjectSpaceProvider.GetDataStoreProvider(connectionString, connection, false);

        in the GetDataStoreProvider method.

        The solution with using the CustomizeTypesInfo method does not depend on if the connection pooling is used. I'd prefer using it.

          Comments (1)

            Hi Gosha,

            Thanks for you help!

            Best Regards,
            Gary

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.