UmbrellaFrame.ModelSync.SQLite
1.0.2
See the version list below for details.
dotnet add package UmbrellaFrame.ModelSync.SQLite --version 1.0.2
NuGet\Install-Package UmbrellaFrame.ModelSync.SQLite -Version 1.0.2
<PackageReference Include="UmbrellaFrame.ModelSync.SQLite" Version="1.0.2" />
<PackageVersion Include="UmbrellaFrame.ModelSync.SQLite" Version="1.0.2" />
<PackageReference Include="UmbrellaFrame.ModelSync.SQLite" />
paket add UmbrellaFrame.ModelSync.SQLite --version 1.0.2
#r "nuget: UmbrellaFrame.ModelSync.SQLite, 1.0.2"
#:package UmbrellaFrame.ModelSync.SQLite@1.0.2
#addin nuget:?package=UmbrellaFrame.ModelSync.SQLite&version=1.0.2
#tool nuget:?package=UmbrellaFrame.ModelSync.SQLite&version=1.0.2
<div align="center">
<img src="assets/icons/modelsync-core.png" alt="ModelSync" width="160"/>
ModelSync
Language / Dil: English - Turkce
</div>
English
Attribute-based SQL schema generator for .NET
Zero ORM dependency - 4 database providers - explicit destructive-operation safety.
ModelSync lets you decorate plain C# classes with attributes and generate or execute SQL DDL for CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE, and CREATE INDEX without Entity Framework or a heavy ORM.
UmbrellaFrame.ModelSync.Core -> Attributes, interfaces, SQL builder
UmbrellaFrame.ModelSync.SqlServer -> SQL Server / Azure SQL provider
UmbrellaFrame.ModelSync.MySql -> MySQL / MariaDB provider
UmbrellaFrame.ModelSync.PostgreSQL -> PostgreSQL provider
UmbrellaFrame.ModelSync.SQLite -> SQLite provider
UmbrellaFrame.ModelSync.Analyzers -> Roslyn compile-time checks
Design Philosophy
ModelSync v1 intentionally favors explicit, developer-controlled schema operations over automatic live-database mutation.
Schema changes can be destructive. Dropping columns, changing column types, truncating tables, or dropping tables can cause data loss if applied automatically. For that reason, ModelSync v1 generates SQL and provides explicit DDL methods, but it does not silently synchronize a live database.
Planned Phase 2 direction:
- compare model attributes with the live database schema
- generate an ALTER TABLE plan before applying it
- support dry-run SQL output
- classify risky and destructive operations
- require explicit opt-in before data-loss operations
Installation
Install only the provider you need:
dotnet add package UmbrellaFrame.ModelSync.SqlServer
dotnet add package UmbrellaFrame.ModelSync.MySql
dotnet add package UmbrellaFrame.ModelSync.PostgreSQL
dotnet add package UmbrellaFrame.ModelSync.SQLite
Each provider package pulls UmbrellaFrame.ModelSync.Core as a dependency.
Optionally add the analyzer package:
dotnet add package UmbrellaFrame.ModelSync.Analyzers
Quick Start
using UmbrellaFrame.ModelSync.Core;
using UmbrellaFrame.ModelSync.MySql;
[MySqlTableName("products")]
public class Product
{
[MySqlColumnType(MySqlColumnType.INT)]
[MySqlColumnPrimaryKey(isAutoIncrement: true)]
public int Id { get; set; }
[MySqlColumnType(MySqlColumnType.VARCHAR, "255")]
[MySqlColumnNotNull]
public string Name { get; set; }
[MySqlColumnType(MySqlColumnType.DECIMAL, "10,2")]
[DbColumnDefault("0.00")]
[DbColumnCheck("Price >= 0")]
public decimal Price { get; set; }
}
var generator = new MySqlTableGenerator(
"Server=localhost;Database=mydb;User=root;Password=pass;"
);
generator.CreateDatabase();
generator.GenerateMySqlTable<Product>(ifNotExists: true);
await generator.CreateTablesAsync(cancellationToken);
Generated SQL:
CREATE TABLE IF NOT EXISTS `products` (
`Id` INT PRIMARY KEY AUTO_INCREMENT,
`Name` VARCHAR(255) NOT NULL,
`Price` DECIMAL(10,2) DEFAULT 0.00 CHECK (Price >= 0)
);
ALTER TABLE Operations
Safe additive operations can run directly:
generator.AddColumn<Product>("Stock");
await generator.AddColumnAsync<Product>("Stock", cancellationToken);
Destructive or risky operations require explicit opt-in:
var allow = DestructiveOperationOptions.Allow();
generator.DropColumn<Product>("LegacyCode", allow);
generator.AlterColumnType<Product>("Price", allow);
generator.DropTables(allow);
await generator.DropColumnAsync<Product>("LegacyCode", allow, cancellationToken);
await generator.AlterColumnTypeAsync<Product>("Price", allow, cancellationToken);
await generator.DropTablesAsync(allow, cancellationToken);
Calling DropColumn, AlterColumnType, or DropTables without DestructiveOperationOptions.Allow() throws an exception by design.
SQLite does not support ALTER COLUMN TYPE directly. Even with destructive permission, SQLite throws NotSupportedException; use a create-copy-drop table rebuild strategy instead.
Identifier Safety
ModelSync uses strict identifier validation before quoting table, column, index, and database names.
Allowed identifier pattern:
^[A-Za-z_][A-Za-z0-9_]*$
This intentionally rejects spaces, dots, quotes, brackets, semicolons, hyphens, and other characters that make generated DDL harder to reason about safely.
Supported Attributes
Provider-specific attributes:
| Attribute | Description |
|---|---|
[{Db}TableName("name")] |
Set table name |
[{Db}ColumnType(Type)] |
Set column data type |
[{Db}ColumnPrimaryKey] |
Mark as primary key |
[{Db}ColumnNotNull] |
Add NOT NULL |
[{Db}ColumnUnique] |
Add UNIQUE |
[{Db}ForeignKey("column","table","ref")] |
Add foreign key |
Cross-provider attributes:
| Attribute | Description |
|---|---|
[DbColumnDefault("expr")] |
Add DEFAULT expression |
[DbColumnCheck("expr")] |
Add CHECK expression |
[DbColumnIndex] |
Generate CREATE INDEX SQL via GenerateIndexSql<T>() |
Roslyn Analyzer
| Rule | Severity | Description |
|---|---|---|
| MSYNC001 | Warning | Public property is missing a column type attribute |
| MSYNC002 | Warning | Class has column attributes but no table name attribute |
| MSYNC003 | Warning | Model table has no primary key defined |
dotnet_diagnostic.MSYNC001.severity = error
dotnet_diagnostic.MSYNC003.severity = none
Documentation
| Document | Description |
|---|---|
| Overview | Architecture and design decisions |
| Quick Start | Working examples per provider |
| Attribute Reference | Attribute list and parameter details |
| Provider Guides | Provider-specific behavior |
| API Reference | Public API details |
| Dependency Injection | ASP.NET Core DI usage |
| Roslyn Analyzers | Analyzer rules |
| Architecture | Internal flow and extension points |
| Contributing | Development setup |
| Changelog | Version history |
Why ModelSync?
| Feature | ModelSync | EF Core | FluentMigrator | DbUp |
|---|---|---|---|---|
| Zero ORM dependency | Yes | No | Yes | Yes |
| Attribute-based schema | Yes | Yes | No | No |
| Provider packages | Yes | Yes | Yes | Yes |
| Async DDL execution | Yes | Yes | Limited | Yes |
| Analyzer support | Yes | No | No | No |
| Explicit destructive safety | Yes | Partial | Manual | Manual |
| Automatic live DB diff | Planned | Yes | No | No |
License
MIT (c) UmbrellaFrame
Turkce
.NET icin attribute tabanli SQL sema uretici
Sifir ORM bagimliligi - 4 veritabani saglayici - yikici islemler icin acik onay guvenligi.
ModelSync, sade C# siniflarini attribute'larla isaretleyerek Entity Framework veya agir bir ORM kullanmadan CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE ve CREATE INDEX DDL'i uretmenizi veya calistirmanizi saglar.
Tasarim Felsefesi
ModelSync v1, canli veritabanini otomatik degistirmek yerine gelistiricinin acikca kontrol ettigi sema islemlerini tercih eder.
Sema degisiklikleri yikici olabilir. Sutun silme, sutun tipi degistirme, tabloyu bosaltma veya tablo silme gibi islemler otomatik uygulanirsa veri kaybina neden olabilir. Bu nedenle ModelSync v1 SQL uretir ve acik DDL metotlari saglar; canli veritabanini sessizce kendi kendine senkronize etmez.
Planlanan Faz 2 yonu:
- model attribute'larini canli veritabani semasiyla karsilastirmak
- uygulamadan once ALTER TABLE plani uretmek
- dry-run SQL ciktisi vermek
- riskli ve yikici islemleri siniflandirmak
- veri kaybi olusturabilecek islemler icin acik onay istemek
Kurulum
dotnet add package UmbrellaFrame.ModelSync.SqlServer
dotnet add package UmbrellaFrame.ModelSync.MySql
dotnet add package UmbrellaFrame.ModelSync.PostgreSQL
dotnet add package UmbrellaFrame.ModelSync.SQLite
dotnet add package UmbrellaFrame.ModelSync.Analyzers
Her saglayici paketi UmbrellaFrame.ModelSync.Core paketini bagimlilik olarak indirir.
Hizli Baslangic
using UmbrellaFrame.ModelSync.Core;
using UmbrellaFrame.ModelSync.MySql;
[MySqlTableName("urunler")]
public class Urun
{
[MySqlColumnType(MySqlColumnType.INT)]
[MySqlColumnPrimaryKey(isAutoIncrement: true)]
public int Id { get; set; }
[MySqlColumnType(MySqlColumnType.VARCHAR, "255")]
[MySqlColumnNotNull]
public string Ad { get; set; }
[MySqlColumnType(MySqlColumnType.DECIMAL, "10,2")]
[DbColumnDefault("0.00")]
[DbColumnCheck("Fiyat >= 0")]
public decimal Fiyat { get; set; }
}
var generator = new MySqlTableGenerator(
"Server=localhost;Database=mydb;User=root;Password=pass;"
);
generator.CreateDatabase();
generator.GenerateMySqlTable<Urun>(ifNotExists: true);
await generator.CreateTablesAsync(cancellationToken);
ALTER TABLE Islemleri
Guvenli ekleme islemleri dogrudan calisabilir:
generator.AddColumn<Urun>("Stok");
await generator.AddColumnAsync<Urun>("Stok", cancellationToken);
Yikici veya riskli islemler acik onay ister:
var allow = DestructiveOperationOptions.Allow();
generator.DropColumn<Urun>("EskiKod", allow);
generator.AlterColumnType<Urun>("Fiyat", allow);
generator.DropTables(allow);
DropColumn, AlterColumnType veya DropTables metotlarini DestructiveOperationOptions.Allow() olmadan cagirmak tasarim geregi exception firlatir.
SQLite ALTER COLUMN TYPE islemini dogrudan desteklemez. Destructive izin verilse bile SQLite saglayicisi NotSupportedException firlatir; tabloyu yeniden olusturup veriyi tasima stratejisi gerekir.
Identifier Guvenligi
ModelSync tablo, kolon, index ve veritabani adlarini quote etmeden once siki sekilde dogrular.
Izin verilen desen:
^[A-Za-z_][A-Za-z0-9_]*$
Bosluk, nokta, tirnak, koseli parantez, noktalı virgul, tire ve benzeri karakterler bilincli olarak reddedilir.
Desteklenen Attribute'lar
| Attribute | Aciklama |
|---|---|
[{Db}TableName("isim")] |
Tablo adini belirler |
[{Db}ColumnType(Tip)] |
Sutun veri tipini belirler |
[{Db}ColumnPrimaryKey] |
Primary key olarak isaretler |
[{Db}ColumnNotNull] |
NOT NULL ekler |
[{Db}ColumnUnique] |
UNIQUE ekler |
[{Db}ForeignKey("sutun","tablo","ref")] |
Foreign key ekler |
[DbColumnDefault("ifade")] |
DEFAULT ifadesi ekler |
[DbColumnCheck("ifade")] |
CHECK ifadesi ekler |
[DbColumnIndex] |
GenerateIndexSql<T>() ile index SQL'i uretir |
Lisans
MIT (c) UmbrellaFrame
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Data.Sqlite (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- UmbrellaFrame.ModelSync.Core (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.