Data.Modeler 4.0.220

There is a newer version of this package available.
See the version list below for details.
dotnet add package Data.Modeler --version 4.0.220                
NuGet\Install-Package Data.Modeler -Version 4.0.220                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Data.Modeler" Version="4.0.220" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Data.Modeler --version 4.0.220                
#r "nuget: Data.Modeler, 4.0.220"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Data.Modeler as a Cake Addin
#addin nuget:?package=Data.Modeler&version=4.0.220

// Install Data.Modeler as a Cake Tool
#tool nuget:?package=Data.Modeler&version=4.0.220                

Data.Modeler

Build status

Data.Modeler is a library used to interact with model database schemas in C#. Works with .Net Core.

Basic Usage

In order to use Data.Modeler, you need to first wire up the system with your ServiceCollection. In order to do this, all you need to do is make one method call:

serviceCollection.AddCanisterModules();
				

This line is required prior to using the DataModeler class for the first time. Once Canister is set up, you can call the DataModeler class provided:

var SchemaProvider = DataModeler.GetSchemaGenerator(SqlClientFactory.Instance);

Note that the above gets the schema provider for SQL Server but for other databases you must provide the DbProviderFactory associated with it. You can also start creating a schema:

var Source = DataModeler.CreateSource("MySource");

The "MySource" string is the database name that you wish to use.

Creating a Schema

Once you have your ISource object, you can start adding on to it:

var Table = Source.AddTable("TableName", "dbo");
var Column = Table.AddColumn<int>("ColumnName",DbType.Int32);
var CheckConstraint = Table.AddCheckConstraint("CheckConstraintName", "Check Constraint Definition");
var View = Source.AddView("ViewName","View Creation Code", "dbo");
var Function = Source.AddFunction("FunctionName","Function Creation Code", "dbo");
var StoredProcedure = Source.AddStoredProcedure("StoredProcedureName","Stored Procedure Creation Code", "dbo");

From there the schema provider can be used to either generate the commands needed to create the database or what commands are needed to alter an existing database to the desired schema:

var MyCommands = SchemaProvider.GenerateSchema(DesiredSchema, SourceSchema);

If SourceSchema is null, then it will treat it as the database doesn't exist. If the SourceSchema is not null, it will act as though the database exists and the DesiredSchema is what you want the final schema to look like. Note that deleting columns, tables, etc. is not done by the system. It will, however, generate calls to drop functions, stored procedures, views, constraints, etc. if they need to be updated. Another thing you can do is have the system apply those changes for you:

SchemaProvider.Setup(DesiredSchema,new Connection(Configuration, SqlClientFactory.Instance, "Default"));

The connection object must be fed a IConfiguration object, a DbProviderFactory for the database type you wish it to connect to, and either the name of your connection string in the configuration object or a connection string:

SchemaProvider.Setup(DesiredSchema,new Connection(Configuration, SqlClientFactory.Instance, "Data Source=localhost;Initial Catalog=ExampleDatabase;Integrated Security=SSPI;Pooling=false"));

Adding a ISchemaGenerator

The schema generator is what the system uses to generate the individual commands. Data.Modeler comes with one for SQL Server but in order to add your own you must create a class that inherits from ISchemaGenerator. From there the system will automatically pick up the schema generator and allow you to use it:

var SchemaProvider = DataModeler.GetSchemaGenerator(MyDbFactoryProvider);

Note that you can also create one for SQL Server and the system will actually return the one that you create instead of the one built into the system.

Installation

The library is available via Nuget with the package name "Data.Modeler". To install it run the following command in the Package Manager Console:

Install-Package Data.Modeler

Build Process

In order to build the library you will require the following as a minimum:

  1. Visual Studio 2022

Other than that, just clone the project and you should be able to load the solution and build without too much effort.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Data.Modeler:

Package Downloads
Inflatable

Inflatable is a simple ORM.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.0.5 54 11/26/2024
5.0.4 95 11/26/2024
5.0.3 64 11/25/2024
5.0.2 100 11/24/2024
5.0.1 78 11/23/2024
5.0.0 79 11/23/2024
4.0.268 94 11/19/2024
4.0.267 81 11/11/2024
4.0.266 72 11/6/2024
4.0.265 72 11/5/2024
4.0.264 72 11/4/2024
4.0.263 81 11/1/2024
4.0.262 71 10/31/2024
4.0.261 73 10/30/2024
4.0.260 76 10/29/2024
4.0.259 72 10/29/2024
4.0.258 83 10/25/2024
4.0.257 75 10/24/2024
4.0.256 77 10/21/2024
4.0.255 89 10/16/2024
4.0.254 72 10/15/2024
4.0.253 84 10/11/2024
4.0.252 82 10/10/2024
4.0.251 88 10/9/2024
4.0.250 91 10/8/2024
4.0.249 84 10/2/2024
4.0.248 80 10/1/2024
4.0.247 88 9/30/2024
4.0.246 88 9/27/2024
4.0.245 86 9/24/2024
4.0.244 96 9/23/2024
4.0.243 84 9/23/2024
4.0.242 123 9/17/2024
4.0.241 114 9/10/2024
4.0.240 97 9/9/2024
4.0.239 95 9/6/2024
4.0.238 100 9/5/2024
4.0.237 105 9/3/2024
4.0.236 107 9/2/2024
4.0.235 102 8/30/2024
4.0.234 104 8/29/2024
4.0.233 105 8/28/2024
4.0.232 104 8/27/2024
4.0.231 113 8/26/2024
4.0.230 126 8/23/2024
4.0.229 119 8/22/2024
4.0.228 123 8/21/2024
4.0.227 122 8/20/2024
4.0.226 121 8/20/2024
4.0.225 142 8/19/2024
4.0.224 134 8/16/2024
4.0.223 116 8/15/2024
4.0.222 130 8/14/2024
4.0.221 97 8/5/2024
4.0.220 95 8/2/2024
4.0.219 106 8/1/2024
4.0.218 85 7/31/2024
4.0.217 104 7/26/2024
4.0.216 82 7/25/2024
4.0.215 62 7/24/2024
4.0.214 114 7/11/2024
4.0.213 97 7/10/2024
4.0.212 90 7/9/2024
4.0.211 89 7/9/2024
4.0.210 93 7/8/2024
4.0.209 108 7/5/2024
4.0.208 102 7/5/2024
4.0.207 100 7/2/2024
4.0.206 94 7/1/2024
4.0.205 112 6/27/2024
4.0.204 97 6/26/2024
4.0.203 111 6/25/2024
4.0.202 102 6/24/2024
4.0.201 955 6/19/2024
4.0.200 114 6/18/2024
4.0.199 91 6/17/2024
4.0.198 98 6/14/2024
4.0.197 96 6/13/2024
4.0.196 104 6/12/2024
4.0.195 119 6/3/2024
4.0.194 106 5/31/2024
4.0.193 120 5/30/2024
4.0.192 103 5/29/2024
4.0.191 127 5/27/2024
4.0.190 94 5/27/2024
4.0.189 99 5/23/2024
4.0.188 109 5/22/2024
4.0.187 139 5/21/2024
4.0.186 113 5/20/2024
4.0.185 119 5/17/2024
4.0.184 116 5/16/2024
4.0.183 122 5/15/2024
4.0.182 117 5/8/2024
4.0.181 98 5/7/2024
4.0.180 118 5/6/2024
4.0.179 115 5/3/2024
4.0.178 679 5/2/2024
4.0.177 84 5/1/2024
4.0.176 110 4/30/2024
4.0.175 111 4/29/2024
4.0.174 111 4/29/2024
4.0.173 116 4/25/2024
4.0.172 115 4/24/2024
4.0.171 121 4/16/2024
4.0.170 118 4/15/2024
4.0.169 103 4/12/2024
4.0.168 105 4/12/2024
4.0.167 121 4/11/2024
4.0.166 131 4/10/2024
4.0.165 119 4/9/2024
4.0.164 120 4/8/2024
4.0.163 121 4/1/2024
4.0.162 107 3/29/2024
4.0.161 106 3/28/2024
4.0.160 100 3/26/2024
4.0.159 130 3/23/2024
4.0.158 118 3/22/2024
4.0.157 113 3/21/2024
4.0.156 107 3/18/2024
4.0.155 133 3/15/2024
4.0.154 120 3/14/2024
4.0.153 130 3/13/2024
4.0.152 138 3/11/2024
4.0.151 121 3/8/2024
4.0.150 127 3/7/2024
4.0.149 122 3/6/2024
4.0.148 119 3/5/2024
4.0.147 945 3/4/2024
4.0.146 142 3/1/2024
4.0.145 135 2/29/2024
4.0.144 128 2/28/2024
4.0.143 135 2/27/2024
4.0.142 123 2/26/2024
4.0.141 152 2/23/2024
4.0.140 127 2/22/2024
4.0.139 129 2/21/2024
4.0.138 135 2/20/2024
4.0.137 378 2/19/2024
4.0.136 112 2/19/2024
4.0.135 109 2/16/2024
4.0.134 113 2/16/2024
4.0.133 110 2/15/2024
4.0.132 122 2/14/2024
4.0.131 112 2/13/2024
4.0.130 143 2/12/2024
4.0.129 113 2/9/2024
4.0.128 152 2/8/2024
4.0.127 125 2/7/2024
4.0.126 131 2/6/2024
4.0.125 99 2/6/2024
4.0.124 113 2/5/2024
4.0.123 467 2/2/2024
4.0.122 119 2/1/2024
4.0.121 116 2/1/2024
4.0.120 126 1/31/2024
4.0.119 203 1/30/2024
4.0.118 126 1/29/2024
4.0.117 142 1/26/2024
4.0.116 115 1/24/2024
4.0.115 110 1/23/2024
4.0.114 116 1/22/2024
4.0.113 309 1/16/2024
4.0.112 155 1/15/2024
4.0.111 126 1/15/2024
4.0.110 131 1/12/2024
4.0.109 111 1/11/2024
4.0.108 126 1/10/2024
4.0.107 299 1/8/2024
4.0.106 180 1/5/2024
4.0.105 309 12/26/2023
4.0.104 135 12/26/2023
4.0.103 168 12/25/2023
4.0.102 139 12/25/2023
4.0.101 220 12/22/2023
4.0.100 161 12/21/2023
4.0.99 184 12/15/2023
4.0.98 138 12/14/2023
4.0.97 124 12/13/2023
4.0.96 143 12/13/2023
4.0.95 307 12/12/2023
4.0.94 139 12/12/2023
4.0.93 143 12/11/2023
4.0.92 137 12/11/2023
4.0.91 204 12/6/2023
4.0.90 153 12/6/2023
4.0.89 144 12/5/2023
4.0.88 200 12/4/2023
4.0.87 209 11/24/2023
4.0.86 160 11/23/2023
4.0.85 147 11/21/2023
4.0.84 159 11/20/2023
4.0.83 148 11/20/2023
4.0.82 185 11/17/2023
4.0.81 442 11/16/2023
4.0.80 150 11/15/2023
4.0.79 160 11/13/2023
4.0.78 172 11/9/2023
4.0.77 184 11/8/2023
4.0.76 137 11/8/2023
4.0.75 147 11/7/2023
4.0.74 163 11/6/2023
4.0.73 161 11/3/2023
4.0.72 194 11/2/2023
4.0.71 146 11/1/2023
4.0.70 132 11/1/2023
4.0.69 181 10/31/2023
4.0.68 169 10/30/2023
4.0.67 172 10/27/2023
4.0.66 171 10/26/2023
4.0.65 181 10/25/2023
4.0.64 175 10/17/2023
4.0.63 134 10/17/2023
4.0.62 195 10/16/2023
4.0.61 198 10/13/2023
4.0.60 208 10/12/2023
4.0.59 163 10/11/2023
4.0.58 194 10/5/2023
4.0.57 164 10/4/2023
4.0.56 160 9/26/2023
4.0.55 160 9/25/2023
4.0.54 178 9/22/2023
4.0.53 178 9/20/2023
4.0.52 173 9/19/2023
4.0.51 174 9/18/2023
4.0.50 157 9/18/2023
4.0.49 220 9/14/2023
4.0.48 184 9/13/2023
4.0.47 159 9/12/2023
4.0.46 239 9/11/2023
4.0.45 149 9/11/2023
4.0.44 145 9/11/2023
4.0.43 266 9/7/2023
4.0.42 154 9/6/2023
4.0.41 208 9/5/2023
4.0.40 164 9/4/2023
4.0.39 160 9/4/2023
4.0.38 194 9/1/2023
4.0.37 207 8/31/2023
4.0.36 196 8/30/2023
4.0.35 217 8/29/2023
4.0.34 150 8/29/2023
4.0.33 236 8/28/2023
4.0.32 213 8/25/2023
4.0.31 206 8/24/2023
4.0.30 190 8/23/2023
4.0.29 200 8/22/2023
4.0.28 201 8/18/2023
4.0.27 200 8/17/2023
4.0.26 186 8/17/2023
4.0.25 173 8/16/2023
4.0.24 257 8/10/2023
4.0.23 218 8/9/2023
4.0.22 207 8/8/2023
4.0.21 189 8/8/2023
4.0.20 303 8/7/2023
4.0.19 197 8/4/2023
4.0.18 256 8/3/2023
4.0.17 221 8/2/2023
4.0.16 225 7/26/2023
4.0.15 212 7/25/2023
4.0.14 234 7/20/2023
4.0.13 214 7/19/2023
4.0.12 205 7/18/2023
4.0.11 158 7/18/2023
4.0.10 216 7/18/2023
4.0.9 169 7/18/2023
4.0.8 277 7/17/2023
4.0.7 174 7/17/2023
4.0.6 546 1/30/2023
4.0.5 401 1/30/2023
4.0.4 403 1/27/2023
4.0.3 506 12/13/2022
4.0.0 321 12/12/2022
3.0.47 1,521 6/10/2022
3.0.45 980 4/20/2022
3.0.44 1,001 1/11/2022
3.0.43 617 1/10/2022
3.0.42 1,088 6/17/2021
3.0.41 745 6/16/2021
3.0.40 712 6/16/2021
3.0.39 501 6/16/2021
3.0.38 978 1/7/2021
3.0.37 816 12/16/2020
3.0.36 754 12/14/2020
3.0.35 2,301 9/13/2020
3.0.34 868 6/19/2020
3.0.33 1,860 5/12/2020
3.0.32 1,381 5/12/2020
3.0.31 877 4/28/2020
3.0.30 830 4/24/2020
3.0.29 815 4/16/2020
3.0.28 886 4/16/2020
3.0.27 560 4/15/2020
3.0.26 850 4/15/2020
3.0.25 908 4/14/2020
3.0.24 590 4/14/2020
3.0.23 935 4/10/2020
3.0.22 876 4/10/2020
3.0.21 912 4/7/2020
3.0.20 2,745 3/26/2020
3.0.19 912 3/26/2020
3.0.18 577 3/25/2020
3.0.17 579 3/25/2020
3.0.16 589 3/25/2020
3.0.15 608 3/25/2020
3.0.13 589 3/25/2020
3.0.12 604 3/25/2020
3.0.11 573 3/25/2020
3.0.10 1,127 3/25/2020
3.0.9 946 3/22/2020
3.0.8 563 3/22/2020
3.0.7 946 3/21/2020
3.0.6 1,588 3/13/2020
3.0.5 606 3/13/2020
3.0.4 1,326 2/28/2020
3.0.3 1,183 2/21/2020
3.0.2 637 2/11/2020
3.0.1 612 2/11/2020
3.0.0 1,784 12/23/2019
2.0.13 628 11/4/2019
2.0.12 695 6/19/2019
2.0.11 682 6/19/2019
2.0.10 974 4/17/2019
2.0.9 1,540 2/21/2019
2.0.8 3,877 8/1/2018
2.0.7 1,219 8/1/2018
2.0.6 1,621 6/26/2018
2.0.5 988 6/14/2018
2.0.4 1,577 6/1/2018
2.0.3 1,534 5/22/2018
2.0.2 2,117 5/11/2018
2.0.1 2,191 2/13/2018
2.0.0 2,088 1/2/2018
1.0.29 3,808 11/16/2017
1.0.28 916 11/16/2017
1.0.27 6,329 10/18/2017
1.0.26 4,526 9/22/2017
1.0.24 992 9/22/2017
1.0.23 1,330 9/22/2017
1.0.22 1,000 9/22/2017
1.0.21 1,003 9/22/2017
1.0.19 1,011 9/22/2017
1.0.18 1,005 9/21/2017
1.0.17 2,050 8/4/2017
1.0.16 1,014 7/3/2017
1.0.15 1,035 6/16/2017
1.0.13 1,026 6/16/2017
1.0.12 1,016 6/16/2017
1.0.11 1,037 5/30/2017
1.0.9 1,029 5/25/2017
1.0.8 1,013 5/24/2017
1.0.7 1,038 5/19/2017
1.0.6 1,072 5/17/2017
1.0.4 1,132 4/3/2017
1.0.3 1,139 3/22/2017
1.0.2 1,131 2/2/2017