Skip to content

Commit 4280517

Browse files
Add documentation
1 parent f55b42b commit 4280517

15 files changed

+372
-247
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
EFCore.Cassandra is an Entity Framework Core provider built on top of [CassandraCSharpDriver](https://github.com/datastax/csharp-driver). It allows you to use EF Core O/RM with cassandra.
77

8+
For project documentation, please visit [readthedocs](https://efcorecassandra.readthedocs.io/en/latest/).
9+
10+
## Packages
11+
12+
| | | | |
13+
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
14+
| `EFCore.Cassandra` | [![MyGet (dev)](https://img.shields.io/myget/advance-ict/v/EFCore.Cassandra.svg)](https://www.myget.org/feed/advance-ict/package/nuget/EFCore.Cassandra) | [![NuGet](https://img.shields.io/nuget/v/EFCore.Cassandra.svg)](https://nuget.org/packages/EFCore.Cassandra) | [![NuGet](https://img.shields.io/nuget/dt/EFCore.Cassandra.svg)](https://nuget.org/packages/EFCore.Cassandra) |
15+
816
## Contributing
917

1018
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ deploy:
2424
- provider: NuGet
2525
name: production
2626
api_key:
27-
secure: sCWC9q0qyTq//EuhS9kjMCqRDWaH5iF//mQrkraUiYoEjbVIWc/YQ3z3cB+wsbce
27+
secure: Uigh51VjtY/sVniNFhkSvZ60/FvI9DyJ/g2feCm/WNdzeN9x5FSiqQwF9Y8qQ6nj
2828
on:
2929
branch: master
3030
appveyor_repo_tag: true

docs/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SOURCEDIR = .
8+
BUILDDIR = _build
9+
10+
# Put it first so that "make" without argument is like "make help".
11+
help:
12+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13+
14+
.PHONY: help Makefile
15+
16+
# Catch-all target: route all unknown targets to Sphinx using the new
17+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18+
%: Makefile
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Configuration file for the Sphinx documentation builder.
4+
#
5+
# This file does only contain a selection of the most common options. For a
6+
# full list see the documentation:
7+
# http://www.sphinx-doc.org/en/master/config
8+
9+
# -- Path setup --------------------------------------------------------------
10+
11+
# If extensions (or modules to document with autodoc) are in another directory,
12+
# add these directories to sys.path here. If the directory is relative to the
13+
# documentation root, use os.path.abspath to make it absolute, like shown here.
14+
#
15+
# import os
16+
# import sys
17+
# sys.path.insert(0, os.path.abspath('.'))
18+
19+
20+
# -- Project information -----------------------------------------------------
21+
22+
project = u'SimpleIdServer'
23+
copyright = u'2019, SimpleIdServer'
24+
author = u'SimpleIdServer'
25+
26+
# The short X.Y version
27+
version = u''
28+
# The full version, including alpha/beta/rc tags
29+
release = u''
30+
31+
32+
# -- General configuration ---------------------------------------------------
33+
34+
# If your documentation needs a minimal Sphinx version, state it here.
35+
#
36+
# needs_sphinx = '1.0'
37+
38+
# Add any Sphinx extension module names here, as strings. They can be
39+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
40+
# ones.
41+
extensions = [
42+
"sphinx_rtd_theme"
43+
]
44+
45+
# Add any paths that contain templates here, relative to this directory.
46+
templates_path = ['_templates']
47+
48+
# The suffix(es) of source filenames.
49+
# You can specify multiple suffix as a list of string:
50+
#
51+
# source_suffix = ['.rst', '.md']
52+
source_suffix = '.rst'
53+
54+
# The master toctree document.
55+
master_doc = 'index'
56+
57+
# The language for content autogenerated by Sphinx. Refer to documentation
58+
# for a list of supported languages.
59+
#
60+
# This is also used if you do content translation via gettext catalogs.
61+
# Usually you set "language" from the command line for these cases.
62+
language = None
63+
64+
# List of patterns, relative to source directory, that match files and
65+
# directories to ignore when looking for source files.
66+
# This pattern also affects html_static_path and html_extra_path.
67+
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store']
68+
69+
# The name of the Pygments (syntax highlighting) style to use.
70+
pygments_style = None
71+
72+
73+
# -- Options for HTML output -------------------------------------------------
74+
75+
# The theme to use for HTML and HTML Help pages. See the documentation for
76+
# a list of builtin themes.
77+
#
78+
html_theme = "sphinx_rtd_theme"
79+
80+
# Theme options are theme-specific and customize the look and feel of a theme
81+
# further. For a list of options available for each theme, see the
82+
# documentation.
83+
#
84+
# html_theme_options = {}
85+
86+
# Add any paths that contain custom static files (such as style sheets) here,
87+
# relative to this directory. They are copied after the builtin static files,
88+
# so a file named "default.css" will overwrite the builtin "default.css".
89+
html_static_path = ['_static']
90+
91+
# Custom sidebar templates, must be a dictionary that maps document names
92+
# to template names.
93+
#
94+
# The default sidebars (for documents that don't match any pattern) are
95+
# defined by theme itself. Builtin themes are using these templates by
96+
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
97+
# 'searchbox.html']``.
98+
#
99+
# html_sidebars = {}
100+
101+
102+
# -- Options for HTMLHelp output ---------------------------------------------
103+
104+
# Output file base name for HTML help builder.
105+
htmlhelp_basename = 'SimpleIdServerdoc'
106+
107+
108+
# -- Options for LaTeX output ------------------------------------------------
109+
110+
latex_elements = {
111+
# The paper size ('letterpaper' or 'a4paper').
112+
#
113+
# 'papersize': 'letterpaper',
114+
115+
# The font size ('10pt', '11pt' or '12pt').
116+
#
117+
# 'pointsize': '10pt',
118+
119+
# Additional stuff for the LaTeX preamble.
120+
#
121+
# 'preamble': '',
122+
123+
# Latex figure (float) alignment
124+
#
125+
# 'figure_align': 'htbp',
126+
}
127+
128+
# Grouping the document tree into LaTeX files. List of tuples
129+
# (source start file, target name, title,
130+
# author, documentclass [howto, manual, or own class]).
131+
latex_documents = [
132+
(master_doc, 'SimpleIdServer.tex', u'SimpleIdServer Documentation',
133+
u'SimpleIdServer', 'manual'),
134+
]
135+
136+
137+
# -- Options for manual page output ------------------------------------------
138+
139+
# One entry per manual page. List of tuples
140+
# (source start file, name, description, authors, manual section).
141+
man_pages = [
142+
(master_doc, 'simpleidserver', u'SimpleIdServer Documentation',
143+
[author], 1)
144+
]
145+
146+
147+
# -- Options for Texinfo output ----------------------------------------------
148+
149+
# Grouping the document tree into Texinfo files. List of tuples
150+
# (source start file, target name, title, author,
151+
# dir menu entry, description, category)
152+
texinfo_documents = [
153+
(master_doc, 'SimpleIdServer', u'SimpleIdServer Documentation',
154+
author, 'SimpleIdServer', 'One line description of project.',
155+
'Miscellaneous'),
156+
]
157+
158+
159+
# -- Options for Epub output -------------------------------------------------
160+
161+
# Bibliographic Dublin Core info.
162+
epub_title = project
163+
164+
# The unique identifier of the text. This can be a ISBN number
165+
# or the project homepage.
166+
#
167+
# epub_identifier = ''
168+
169+
# A unique identification for the text.
170+
#
171+
# epub_uid = ''
172+
173+
# A list of files that should not be packed into the epub file.
174+
epub_exclude_files = ['search.html']

docs/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Welcome to EFCore.Cassandra
2+
===========================
3+
4+
EFCore.Cassandra is an Entity Framework Core provider built on top of CassandraCSharpDriver_. It allows you to use EF Core O/RM with cassandra.
5+
6+
Github: https://github.com/simpleidserver/EFCore.Cassandra
7+
8+
Nuget feed: https://www.myget.org/F/advance-ict/api/v3/index.json
9+
10+
.. toctree::
11+
:maxdepth: 3
12+
:hidden:
13+
:caption: Getting started
14+
15+
intro/getting-started-with-efcorecassandra
16+
17+
.. _CassandraCSharpDriver: https://github.com/datastax/csharp-driver
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
Getting started with Entity Framework Core provider for Cassandra
2+
=================================================================
3+
4+
.. note:: Sample project can be found on this url_.
5+
6+
Install the nuget package
7+
-------------------------
8+
9+
Create an empty DOTNET CORE project and install the nuget package ``EFCore.Cassandra``.
10+
Similarly to any EFCore project, create a class which inherits ``DbContext`` and add models.
11+
12+
Configure DbContext
13+
-------------------
14+
15+
Open the ``DbContext`` implementation, override the ``OnConfiguring`` method and configure database access::
16+
17+
optionsBuilder.UseCassandra("Contact Points=127.0.0.1;", opt =>
18+
{
19+
opt.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "<schema name>");
20+
});
21+
22+
Configure keyspaces
23+
^^^^^^^^^^^^^^^^^^^
24+
25+
**Definition** : A keyspace in Cassandra is a namespace that defines data replication on nodes. A cluster contains one keyspace per node.
26+
27+
In order to configure a keyspace, open the ``DbContext`` implementation and insert the following line in the ``OnModelCreating`` method::
28+
29+
modelBuilder.ForCassandraAddKeyspace("<keyspace name>", KeyspaceReplicationSimpleStrategyClass());
30+
31+
This method contains two parameters:
32+
33+
- Keyspace name.
34+
- Replication strategy.
35+
36+
There are two replication strategies:
37+
38+
- **KeyspaceReplicationSimpleStrategyClass** : Use only for a single datacenter and one rack.
39+
- **KeyspaceReplicationNetworkTopologyStrategyClass** : Use when you have your cluster deployed across multiple datacenters.
40+
41+
Configure tables
42+
^^^^^^^^^^^^^^^^
43+
44+
**Definition** : data is stored in tables containing rows of columns, similar to SQL definitions.
45+
46+
In order to configure one table, open the ``DbContext`` implementation and insert the following line in the ``OnModelCreating`` method::
47+
48+
modelBuilder.Entity<Applicant>()
49+
.ToTable("applicants", "cv")
50+
.HasKey(p => new { p.Id, p.LastName });
51+
modelBuilder.Entity<Applicant>()
52+
.ForCassandraSetClusterColumns(s => new { s.LastName });
53+
54+
The method ``ToTable`` contains two parameters::
55+
56+
- Table name.
57+
- Keyspace name.
58+
59+
Add migrations
60+
--------------
61+
62+
Once the ``DbContext`` implementation is configured, run the command ``dotnet ef migrations add InitialCreate`` to add migration scripts.
63+
Run the command ``dotnet ef database update`` to deploy the migration scripts.
64+
65+
With the TablePlus_ tool you should see something like this:
66+
67+
.. image:: images/tables.png
68+
:align: center
69+
70+
CRUD operations
71+
---------------
72+
73+
Once everything is set up, you can start playing with the ``DbContext``, use LINQ to run operations like ``Create``, ``Delete``, ``Update`` or ``Select``::
74+
75+
using (var dbContext = new FakeDbContext())
76+
{
77+
dbContext.Applicants.Add(BuildApplicant());
78+
dbContext.SaveChanges();
79+
}
80+
81+
.. _url: https://github.com/simpleidserver/EFCore.Cassandra/tree/master/samples/EFCore.Cassandra.Samples
82+
.. _TablePlus: https://tableplus.com/

docs/intro/images/tables.png

12.9 KB
Loading

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
33+
34+
:end
35+
popd

0 commit comments

Comments
 (0)