Skip to content

Instantly share code, notes, and snippets.

View roji's full-sized avatar

Shay Rojansky roji

View GitHub Profile
await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
using var ctx = new BlogContext();
var services = new ServiceCollection()
.AddEntityFrameworkDesignTimeServices()
.AddDbContextDesignTimeServices(ctx);
@roji
roji / Program.cs
Created May 8, 2025 09:38
Sample hello world app using Microsoft.Data.Sqlite with sqlite_vec
using System;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Data.Sqlite;
const string PATH = "/tmp/foo.sqlite";
File.Delete(PATH);
await using var connection = new SqliteConnection($"Data Source={PATH}");
connection.LoadVector();
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
// Note: QdrantVectorStoreClient is a thing I shoved in which basically wraps a typical vector DB client.
// In this sketch, it implements IVectorCollectionStore (which can be seen as a view over the SDK client's capabilities)
{
// Super basic, non-DI usage scenario, no database-specific options
await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
=> configurationBuilder.Properties<ReadOnlyMemory<byte>>().HaveConversion<ReadOnlyMemoryConverter>();