-
Notifications
You must be signed in to change notification settings - Fork 224
Closed
Description
Vector support (Azure or SQL Server 2025)
[Column(TypeName = "vector(1536)")]
public SqlVector<float> Embedding { get; set; }JSON type support (Azure or SQL Server 2025)
public class Blog
{
public int Id { get; set; }
public required BlogDetails Details { get; set; }
}
public class BlogDetails { ... }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>().ComplexProperty(b => b.Details, b => b.ToJson());
}CREATE TABLE [Blogs] (
...
[Details] json NOT NULL,
);JSON
Instead of
CREATE TABLE [Customers] (
[Id] int NOT NULL IDENTITY,
[Name] nvarchar(max) NOT NULL,
[BillingAddress_City] nvarchar(max) NOT NULL,
[BillingAddress_PostalCode] nvarchar(max) NOT NULL,
[BillingAddress_Street] nvarchar(max) NOT NULL,
[BillingAddress_StreetNumber] int NOT NULL,
[ShippingAddress_City] nvarchar(max) NOT NULL,
[ShippingAddress_PostalCode] nvarchar(max) NOT NULL,
[ShippingAddress_Street] nvarchar(max) NOT NULL,
[ShippingAddress_StreetNumber] int NOT NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY ([Id])
);You can now have
public class Customer
{
...
public Address ShippingAddress { get; set; }
public Address? BillingAddress { get; set; }
}
...
modelBuilder.Entity<Customer>(b =>
{
b.ComplexProperty(c => c.ShippingAddress, c => c.ToJson());
b.ComplexProperty(c => c.BillingAddress, c => c.ToJson());
});CREATE TABLE [Customers] (
[Id] int NOT NULL IDENTITY,
[Name] nvarchar(max) NOT NULL,
[ShippingAddress] json NOT NULL,
[BillingAddress] json NOT NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY ([Id])
);This can make it tricky as you have no idea what model is stored in the json unless you read a row.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels