Data.Modeler 4.0.228

There is a newer version of this package available.
See the version list below for details.
dotnet add package Data.Modeler --version 4.0.228                
NuGet\Install-Package Data.Modeler -Version 4.0.228                
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.228" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Data.Modeler --version 4.0.228                
#r "nuget: Data.Modeler, 4.0.228"                
#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.228

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

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
4.0.246 0 9/27/2024
4.0.245 27 9/24/2024
4.0.244 77 9/23/2024
4.0.243 66 9/23/2024
4.0.242 101 9/17/2024
4.0.241 99 9/10/2024
4.0.240 82 9/9/2024
4.0.239 78 9/6/2024
4.0.238 85 9/5/2024
4.0.237 90 9/3/2024
4.0.236 93 9/2/2024
4.0.235 90 8/30/2024
4.0.234 94 8/29/2024
4.0.233 93 8/28/2024
4.0.232 92 8/27/2024
4.0.231 103 8/26/2024
4.0.230 116 8/23/2024
4.0.229 108 8/22/2024
4.0.228 112 8/21/2024
4.0.227 109 8/20/2024
4.0.226 109 8/20/2024
4.0.225 131 8/19/2024
4.0.224 123 8/16/2024
4.0.223 104 8/15/2024
4.0.222 119 8/14/2024
4.0.221 84 8/5/2024
4.0.220 85 8/2/2024
4.0.219 96 8/1/2024
4.0.218 78 7/31/2024
4.0.217 94 7/26/2024
4.0.216 72 7/25/2024
4.0.215 54 7/24/2024
4.0.214 105 7/11/2024
4.0.213 89 7/10/2024
4.0.212 83 7/9/2024
4.0.211 82 7/9/2024
4.0.210 87 7/8/2024
4.0.209 101 7/5/2024
4.0.208 95 7/5/2024
4.0.207 94 7/2/2024
4.0.206 89 7/1/2024
4.0.205 107 6/27/2024
4.0.204 92 6/26/2024
4.0.203 106 6/25/2024
4.0.202 97 6/24/2024
4.0.201 781 6/19/2024
4.0.200 108 6/18/2024
4.0.199 85 6/17/2024
4.0.198 93 6/14/2024
4.0.197 91 6/13/2024
4.0.196 100 6/12/2024
4.0.195 115 6/3/2024
4.0.194 98 5/31/2024
4.0.193 116 5/30/2024
4.0.192 98 5/29/2024
4.0.191 123 5/27/2024
4.0.190 89 5/27/2024
4.0.189 95 5/23/2024
4.0.188 105 5/22/2024
4.0.187 135 5/21/2024
4.0.186 109 5/20/2024
4.0.185 115 5/17/2024
4.0.184 111 5/16/2024
4.0.183 117 5/15/2024
4.0.182 113 5/8/2024
4.0.181 94 5/7/2024
4.0.180 112 5/6/2024
4.0.179 108 5/3/2024
4.0.178 674 5/2/2024
4.0.177 80 5/1/2024
4.0.176 105 4/30/2024
4.0.175 107 4/29/2024
4.0.174 107 4/29/2024
4.0.173 112 4/25/2024
4.0.172 109 4/24/2024
4.0.171 116 4/16/2024
4.0.170 114 4/15/2024
4.0.169 99 4/12/2024
4.0.168 101 4/12/2024
4.0.167 117 4/11/2024
4.0.166 127 4/10/2024
4.0.165 114 4/9/2024
4.0.164 116 4/8/2024
4.0.163 113 4/1/2024
4.0.162 102 3/29/2024
4.0.161 102 3/28/2024
4.0.160 96 3/26/2024
4.0.159 125 3/23/2024
4.0.158 114 3/22/2024
4.0.157 108 3/21/2024
4.0.156 101 3/18/2024
4.0.155 127 3/15/2024
4.0.154 114 3/14/2024
4.0.153 124 3/13/2024
4.0.152 134 3/11/2024
4.0.151 117 3/8/2024
4.0.150 120 3/7/2024
4.0.149 118 3/6/2024
4.0.148 113 3/5/2024
4.0.147 939 3/4/2024
4.0.146 136 3/1/2024
4.0.145 129 2/29/2024
4.0.144 113 2/28/2024
4.0.143 128 2/27/2024
4.0.142 117 2/26/2024
4.0.141 142 2/23/2024
4.0.140 119 2/22/2024
4.0.139 123 2/21/2024
4.0.138 131 2/20/2024
4.0.137 372 2/19/2024
4.0.136 108 2/19/2024
4.0.135 104 2/16/2024
4.0.134 108 2/16/2024
4.0.133 105 2/15/2024
4.0.132 115 2/14/2024
4.0.131 106 2/13/2024
4.0.130 139 2/12/2024
4.0.129 108 2/9/2024
4.0.128 148 2/8/2024
4.0.127 116 2/7/2024
4.0.126 116 2/6/2024
4.0.125 91 2/6/2024
4.0.124 109 2/5/2024
4.0.123 463 2/2/2024
4.0.122 115 2/1/2024
4.0.121 109 2/1/2024
4.0.120 119 1/31/2024
4.0.119 199 1/30/2024
4.0.118 122 1/29/2024
4.0.117 138 1/26/2024
4.0.116 109 1/24/2024
4.0.115 105 1/23/2024
4.0.114 111 1/22/2024
4.0.113 304 1/16/2024
4.0.112 148 1/15/2024
4.0.111 114 1/15/2024
4.0.110 124 1/12/2024
4.0.109 105 1/11/2024
4.0.108 121 1/10/2024
4.0.107 294 1/8/2024
4.0.106 175 1/5/2024
4.0.105 299 12/26/2023
4.0.104 122 12/26/2023
4.0.103 162 12/25/2023
4.0.102 133 12/25/2023
4.0.101 215 12/22/2023
4.0.100 154 12/21/2023
4.0.99 178 12/15/2023
4.0.98 134 12/14/2023
4.0.97 120 12/13/2023
4.0.96 136 12/13/2023
4.0.95 303 12/12/2023
4.0.94 129 12/12/2023
4.0.93 139 12/11/2023
4.0.92 132 12/11/2023
4.0.91 200 12/6/2023
4.0.90 148 12/6/2023
4.0.89 140 12/5/2023
4.0.88 196 12/4/2023
4.0.87 202 11/24/2023
4.0.86 154 11/23/2023
4.0.85 143 11/21/2023
4.0.84 155 11/20/2023
4.0.83 143 11/20/2023
4.0.82 181 11/17/2023
4.0.81 395 11/16/2023
4.0.80 146 11/15/2023
4.0.79 156 11/13/2023
4.0.78 168 11/9/2023
4.0.77 179 11/8/2023
4.0.76 133 11/8/2023
4.0.75 143 11/7/2023
4.0.74 158 11/6/2023
4.0.73 157 11/3/2023
4.0.72 189 11/2/2023
4.0.71 142 11/1/2023
4.0.70 127 11/1/2023
4.0.69 177 10/31/2023
4.0.68 165 10/30/2023
4.0.67 167 10/27/2023
4.0.66 167 10/26/2023
4.0.65 177 10/25/2023
4.0.64 171 10/17/2023
4.0.63 129 10/17/2023
4.0.62 191 10/16/2023
4.0.61 193 10/13/2023
4.0.60 203 10/12/2023
4.0.59 159 10/11/2023
4.0.58 183 10/5/2023
4.0.57 159 10/4/2023
4.0.56 156 9/26/2023
4.0.55 156 9/25/2023
4.0.54 170 9/22/2023
4.0.53 168 9/20/2023
4.0.52 168 9/19/2023
4.0.51 170 9/18/2023
4.0.50 146 9/18/2023
4.0.49 216 9/14/2023
4.0.48 180 9/13/2023
4.0.47 154 9/12/2023
4.0.46 235 9/11/2023
4.0.45 139 9/11/2023
4.0.44 141 9/11/2023
4.0.43 261 9/7/2023
4.0.42 150 9/6/2023
4.0.41 202 9/5/2023
4.0.40 157 9/4/2023
4.0.39 156 9/4/2023
4.0.38 190 9/1/2023
4.0.37 201 8/31/2023
4.0.36 186 8/30/2023
4.0.35 213 8/29/2023
4.0.34 140 8/29/2023
4.0.33 226 8/28/2023
4.0.32 208 8/25/2023
4.0.31 201 8/24/2023
4.0.30 185 8/23/2023
4.0.29 194 8/22/2023
4.0.28 197 8/18/2023
4.0.27 195 8/17/2023
4.0.26 181 8/17/2023
4.0.25 169 8/16/2023
4.0.24 253 8/10/2023
4.0.23 213 8/9/2023
4.0.22 203 8/8/2023
4.0.21 184 8/8/2023
4.0.20 299 8/7/2023
4.0.19 193 8/4/2023
4.0.18 252 8/3/2023
4.0.17 217 8/2/2023
4.0.16 220 7/26/2023
4.0.15 208 7/25/2023
4.0.14 224 7/20/2023
4.0.13 210 7/19/2023
4.0.12 200 7/18/2023
4.0.11 154 7/18/2023
4.0.10 205 7/18/2023
4.0.9 165 7/18/2023
4.0.8 270 7/17/2023
4.0.7 170 7/17/2023
4.0.6 542 1/30/2023
4.0.5 396 1/30/2023
4.0.4 399 1/27/2023
4.0.3 502 12/13/2022
4.0.0 315 12/12/2022
3.0.47 1,517 6/10/2022
3.0.45 976 4/20/2022
3.0.44 996 1/11/2022
3.0.43 613 1/10/2022
3.0.42 1,083 6/17/2021
3.0.41 741 6/16/2021
3.0.40 707 6/16/2021
3.0.39 497 6/16/2021
3.0.38 973 1/7/2021
3.0.37 812 12/16/2020
3.0.36 750 12/14/2020
3.0.35 2,296 9/13/2020
3.0.34 863 6/19/2020
3.0.33 1,854 5/12/2020
3.0.32 1,376 5/12/2020
3.0.31 871 4/28/2020
3.0.30 825 4/24/2020
3.0.29 809 4/16/2020
3.0.28 882 4/16/2020
3.0.27 556 4/15/2020
3.0.26 845 4/15/2020
3.0.25 904 4/14/2020
3.0.24 579 4/14/2020
3.0.23 927 4/10/2020
3.0.22 871 4/10/2020
3.0.21 908 4/7/2020
3.0.20 2,740 3/26/2020
3.0.19 908 3/26/2020
3.0.18 566 3/25/2020
3.0.17 569 3/25/2020
3.0.16 585 3/25/2020
3.0.15 603 3/25/2020
3.0.13 584 3/25/2020
3.0.12 599 3/25/2020
3.0.11 568 3/25/2020
3.0.10 1,123 3/25/2020
3.0.9 939 3/22/2020
3.0.8 559 3/22/2020
3.0.7 942 3/21/2020
3.0.6 1,578 3/13/2020
3.0.5 602 3/13/2020
3.0.4 1,319 2/28/2020
3.0.3 1,178 2/21/2020
3.0.2 631 2/11/2020
3.0.1 599 2/11/2020
3.0.0 1,774 12/23/2019
2.0.13 623 11/4/2019
2.0.12 689 6/19/2019
2.0.11 676 6/19/2019
2.0.10 970 4/17/2019
2.0.9 1,535 2/21/2019
2.0.8 3,869 8/1/2018
2.0.7 1,214 8/1/2018
2.0.6 1,612 6/26/2018
2.0.5 976 6/14/2018
2.0.4 1,569 6/1/2018
2.0.3 1,525 5/22/2018
2.0.2 2,109 5/11/2018
2.0.1 2,184 2/13/2018
2.0.0 2,076 1/2/2018
1.0.29 3,803 11/16/2017
1.0.28 909 11/16/2017
1.0.27 6,321 10/18/2017
1.0.26 4,519 9/22/2017
1.0.24 987 9/22/2017
1.0.23 1,324 9/22/2017
1.0.22 995 9/22/2017
1.0.21 997 9/22/2017
1.0.19 1,006 9/22/2017
1.0.18 998 9/21/2017
1.0.17 2,045 8/4/2017
1.0.16 1,009 7/3/2017
1.0.15 1,028 6/16/2017
1.0.13 1,019 6/16/2017
1.0.12 1,010 6/16/2017
1.0.11 1,032 5/30/2017
1.0.9 1,024 5/25/2017
1.0.8 1,007 5/24/2017
1.0.7 1,033 5/19/2017
1.0.6 1,067 5/17/2017
1.0.4 1,119 4/3/2017
1.0.3 1,131 3/22/2017
1.0.2 1,123 2/2/2017