Forum Discussion
Rayfin/Fabric Apps: support for mapping @entity() to a non-dbo SQL schema
Hello,
We are developing a Microsoft Fabric App using Fabric Apps / Rayfin SDK version 1.33.1.
We need to organize the physical SQL tables by application module using custom schemas, for example:
- schema_1.table_1
- schema_2.table_1
However, the current Rayfin code-first generation appears to use the default dbo schema and generates unqualified table sources.
We would like to confirm whether Rayfin supports mapping an @entity() to a table in a non-dbo schema.
Is using a non-dbo SQL schema supported by Rayfin/Fabric Apps? If supported, what is the exact decorator, configuration, or rayfin.yml syntax?
Regards,
Hello v-abhinavmu
Thank you very much for your response and for taking the time to review the reproduction and provide the relevant documentation.
Unfortunately, this does not fully resolve our use case, as we have not been able to find a supported way to write directly to an entity or object located in a non-dbo schema using the current Rayfin SDK.
For now, we will continue with our current workaround and wait for the Generally Available version of Fabric Apps to see whether support or additional configuration options for non-dbo schemas are introduced or documented.
Thank you again for your help and clarification.
Best regards,
5 Replies
- v-abhinavmu
Community Support
Hi PedroSergey10,
Thanks for reaching out to the Microsoft Fabric Community forum.
Based on the current Microsoft Fabric Apps documentation, the data model is defined using TypeScript decorators, with each entity represented by a class decorated with @entity(). The documentation describes the supported field decorators, relationships, and entity registration, and the generated database schema is based on these TypeScript data model definitions.
The documented rayfin/rayfin.yml configuration includes the services.data settings, such as enabling the data service and specifying the database dialect (mssql). The project structure documentation describes the available configuration options but does not show a schema-mapping property in the documented services.data configuration.
Microsoft also documents that npx rayfin up applies the database schema generated from the TypeScript data model decorators, while npx rayfin up db apply can be used to apply subsequent data-model changes.
Could you share the @entity() definition and the relevant rayfin.yml section from your Rayfin SDK 1.33.1 project (with any sensitive information removed)? That may help clarify whether there is a specific configuration or syntax for schema mapping in your scenario.
For more details, please refer to the below official Microsoft documentation:
Define data models for Fabric Apps - Microsoft Fabric | Microsoft Learn
Fabric Apps project structure - Microsoft Fabric | Microsoft Learn
Deploy a Fabric App to Fabric - Microsoft Fabric | Microsoft Learn
Create and deploy your first Fabric app with the Rayfin CLI - Microsoft Fabric | Microsoft Learn
I hope this helps. Please feel free to reach out if you have any further questions.
Thank you.- PedroSergey10Regular Visitor
Hi, thank you for your detailed response. v-abhinavmu
Below is a sanitized reproduction from our Microsoft Fabric App. Sensitive information such as tenant IDs, workspace IDs, application IDs and redirect URLs has been removed.
Environment
- Microsoft Fabric App
- Rayfin SDK and CLI version: 1.33.1
- Database dialect: mssql
- TypeScript data model using @entity()
- Data API configuration generated by Rayfin/DAB
Relevant rayfin.yml:
-services:
--auth:
--enabled: true
--fabric:
---enabled: true
-data:
--enabled: true
--dialect: mssqlThere is no schema-related property in our services.data configuration.
Entity definitions
@entity("entity_1")
export class class_entity_1{
@uuid() id!: string;
text() collection_id!: string;
date() opened_at!: Date;
}@entity("entity_2")
export class class_entity_2{
@uuid() id!: string;
text() quote_number!: string;
@decimal({ optional: true }) adr_budget?: number;
}We would like to store the physical tables in separate schemas (i.e. schema_1.table_1), without using other implementations.
We currently use a simple dbo compatibility view:
CREATE VIEW dbo.schema_1_table_1 AS SELECT * FROM schema_1.table_1;
Is this an officially supported workaround, including for inserts and updates?
Thank you in advance,
- v-abhinavmu
Community Support
Hi PedroSergey10,
Thank you for providing the sanitized reproduction and the additional details.Based on the Microsoft documentation referenced above, Fabric Apps uses TypeScript decorators such as @entity() to define the data model, and the Rayfin CLI generates the database schema and API configuration from those definitions. The documented services.data configuration specifies the database dialect, such as mssql.
The Microsoft documentation referenced above does not describe an @entity() mapping to a SQL view, nor does it specify how Rayfin/DAB handles create(), update(), or delete() operations when the underlying object is a view over a table in another schema.
If you have additional Rayfin or DAB documentation that specifically describes mapping an entity to a non-dbo schema or SQL view, sharing it would help clarify the supported configuration for Rayfin SDK 1.33.1.
For more details, please refer to the below official Microsoft documentation:
Define data models for Fabric Apps - Microsoft Fabric | Microsoft LearnFabric Apps project structure - Microsoft Fabric | Microsoft Learn
Programming model overview - Microsoft Fabric | Microsoft Learn
Deploy a Fabric App to Fabric - Microsoft Fabric | Microsoft Learn
Read and write data with GraphQL in Fabric Apps - Microsoft Fabric | Microsoft Learn
I hope this helps. Please feel free to reach out if you have any further questions.
Thank you.