Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I have an empty SQL database in Fabric. Grok wrote a few POCOs and created a DBContext for me. Grok then told me to do this:
dotnet ef migrations add InitialCreate
That run okay with this warning:
PS C:\Users\seary\source\repos\UITS-seary-language-helper> dotnet ef migrations add InitialCreate
Build started...
Build succeeded.
The Entity Framework tools version '9.0.6' is older than that of the runtime '9.0.9'. Update the tools for the latest features and bug fixes. See https://aka.ms/AAc1fbw for more information.
Done. To undo this action, use 'ef migrations remove'
but I don't see the tables anywhere in the DB.
Then Grok told me to do this:
dotnet ef database update
Which eventually terminated with the error:
PROCEDURE 'sp_getapplock' is not supported.
Is it possible to do EntityFramework Code First developement in a Fabric SQL Database? If not, when will that be supported?
Solved! Go to Solution.
Hi @Shawn_Eary -
EF Core migrations do work with SQL database in Fabric, there's a mistake in the previous reply.
It appears you may have grabbed the connection information for the read-only SQL analytics endpoint instead of the SQL database in Fabric - an understandable point of confusion that's come up a few times.
Your connection string for SQL db in Fabric would look similar to:
Hi @Shawn_Eary -
EF Core migrations do work with SQL database in Fabric, there's a mistake in the previous reply.
It appears you may have grabbed the connection information for the read-only SQL analytics endpoint instead of the SQL database in Fabric - an understandable point of confusion that's come up a few times.
Your connection string for SQL db in Fabric would look similar to:
Entity Framework is now working in a Fabric SQL Database for me. I have not created a new table yet, but I migrated an Azure SQL Server database over to Fabric and I am able to read from and update it as expected using the .database.fabric.microsoft.com endpoint.
We should consider this ticket closed unless I run into a problem later when creating a new table/POCO. Even if I have a problem, I have a way by which I can continue to use Entity Framework with Fabric SQL Database.
Thanks Microsoft!!!!
Is there some kind of firewall setting that needs to be toggled? The only way I can connect to a Fabric SQL database through the write/update endpoint "[myServerName].database.fabric.microsoft.com,1433" is to use the Open In -> SQL Server Management Studio menu option inside the Fabric Web Portal.
Attempts to connect via Entity Framework.Core using C# fail as well. It feels like there is a setting my tenant admin needs to clear for me.
Hmm, that is odd. There's no firewall settings to configure on the Fabric side. What other connection options are failing for you?
I wonder if these apps are attempting to connect to "<default>" or "master", instead of the specific database.
We can try out a plain C# console app and see if that gives us any insights into the connectivity -
ConnectionTester.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
appsettings.json
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=yourcxninfo.database.fabric.microsoft.com,1433;Initial Catalog=AdventureWorks-20ba15a4-b4f9-4d46-ad10-ddd9d0b7a6ea;Multiple Active Result Sets=False;Connect Timeout=30;Encrypt=True;Trust Server Certificate=False;Authentication=Active Directory Interactive"
}
}
Program.cs
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using System.Diagnostics;
namespace ConnectionTester;
class Program
{
private static IConfiguration? _configuration;
static async Task Main(string[] args)
{
// Build configuration from appsettings.json
_configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
Console.WriteLine("SQL Database Connection Tester");
Console.WriteLine("==============================");
Console.WriteLine();
var connectionString = _configuration?.GetConnectionString("DefaultConnection");
if (string.IsNullOrEmpty(connectionString))
{
Console.WriteLine("✗ Error: No connection string found in appsettings.json");
return;
}
await TestDatabaseConnectionAsync(connectionString);
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
private static async Task TestDatabaseConnectionAsync(string connectionString)
{
var stopwatch = Stopwatch.StartNew();
try
{
Console.WriteLine("Attempting to connect to the database...");
using var connection = new SqlConnection(connectionString);
// Test opening the connection
await connection.OpenAsync();
Console.WriteLine("✓ Successfully connected to the database!");
// Test executing a simple query
Console.WriteLine("Testing query execution...");
using var command = new SqlCommand("SELECT @@VERSION as ServerVersion, GETDATE() as CurrentTime", connection);
using var reader = await command.ExecuteReaderAsync();
if (await reader.ReadAsync())
{
Console.WriteLine("✓ Query execution successful!");
Console.WriteLine($" Current Server Time: {reader["CurrentTime"]}");
}
stopwatch.Stop();
Console.WriteLine($"✓ Connection test completed successfully in {stopwatch.ElapsedMilliseconds}ms");
}
catch (SqlException sqlEx)
{
stopwatch.Stop();
Console.WriteLine($"✗ SQL Server error occurred after {stopwatch.ElapsedMilliseconds}ms:");
Console.WriteLine($" Error Number: {sqlEx.Number}; Severity: {sqlEx.Class}; State: {sqlEx.State}; Message: {sqlEx.Message}");
}
catch (Exception ex)
{
stopwatch.Stop();
Console.WriteLine($"✗ General error occurred after {stopwatch.ElapsedMilliseconds}ms:");
Console.WriteLine($" Type: {ex.GetType().Name}");
Console.WriteLine($" Message: {ex.Message}");
}
}
}
This C# program works as expected for me. I'm still looking into my other issues.
Hi @Shawn_Eary ,
Thank you for reaching out to Microsoft Fabric Community.
EF Core can be used to connect to Fabric SQL DB and carry out basic CRUD operations. However, EF Core Migrations that depend on unsupported system procedures are not available. As an alternative, you can manually create SQL scripts from your EF model and execute them in Fabric, though this disrupts the Code First automation process.
Thank you!!