How to use sqlite database on ubuntu server - c#

I wanted to use sqlite on my server for my asp.net core application, but I'm having trouble undestanding how to communicate with it. There is no information about how to create a connection string for it, and I saw comments that it is not a server/client database type, but I see comments where people say they use sqlite on their servers, so my question is how do they do it?
I want to work on my project and build my database structure with code-first approach locally, push changes to the server and let the database work on the server. I added sqlite to my entity framework in the project with:
services.AddEntityFrameworkSqlite().AddDbContext<TetrominoContext>(options => options.UseSqlite(Configuration.GetConnectionString("SqliteConnection")));
But I don't know how to build the connection string.
If I were to create a db file on the ubuntu server then how do I specify path to that file in my application?

Connection strings in Microsoft.Data.Sqlite look like this:
Filename=/path/to/my.db

Related

How to connect Sqlite database to c# wpf application? And how does deployment work?

I want to connect my Sqlite database to my C# WPF desktop application. How can i do that in the most efficient way? And i want to know about what happens to that db connection when i want to deploy a setup and want to use this application in another computer?(Will that db connection work in other computers?)
Here is link where is it explain in detail how to use sqlite in c#.
https://www.codeguru.com/csharp/.net/net_data/using-sqlite-in-a-c-application.html.
Db connection will work on other computer if deploy packages required for sqlite.

Publishing ASP MVC 5 code-first EF along with it's localdb

I have an ASP MVC 5 application using Code First EF. I am setting up an environment to debug on a remote machine and follow these steps.
The website itself publishes fine, but I'm needing to publish the EF local databases along with it as well, content included. I've been digging around online but have had difficulty finding a step-by-step process for doing this that also allows for EF code first updates to the remote database.
Any help would be appreciated.
As for connection , try modifying the connection string in webConfig. As for the information, I'm not 100% sure on this, but I'd you think you would be able to backup the database and restore on the remote machine.
There is a _migrationHistory table in the database that EF refers to when checking the models against the database, so by restoring the whole database (and the _table as the result ) EF should not lose its state ( you won't need to run Update-Database).
If you publish to a server, you can use different appsettings for development and production using different web.config-files as described here
And for your database:
I pretend you want some content of your database being transferred into the production database in addition to get the right structure of tables too.
In this case, Migrations could do the job:
If you create your database with CodeFirstMigrations you can be sure, that your structure is right, by migrating the database before publishing.
And for the data, you can use a Database-Initializer to get the required data into any database your targeting as long you have enough permission for this.

C# Sql-server on every client

I want to build an application that needs a sql database on every machine that uses the application.
Isn't it true that Chrome and Firefox store cookies in a SQL database? I did not remember installing anything like a SQL server while installing Chrome, so my question is: does every user has to install a SQL Server if my app uses one?
The best thing for your purpose is to use database servers, which will be started with your application, like SQLite or Sql Server Compact. That means, you application host the database it self and you have access over ADO.Net. This is a very smart kind of storing local data and very easy.
Do not try to install complex database systems like mssql, sybase or mysql on every client.
For example, SQLite can be delivered with a few assemblies in your product.
This answers gives a nice overview: Lightweight SQL database which doesn't require installation
In order to store information for a client application, you can use SQL Server Compact, or some other solution, like SQLite (with a library to access it).
There are other alternatives, but these two are the most common and stable.
It's true that Firefox stores cookies in a sqlite database. However, that's not the same thing as SQL Server.
If your app needs to communicate with a database, you can a) bundle a sqlite database with it, b) require an existing database on startup (Wordpress does this; you can pass it details for a mysql database to get it to use an existing installation), or c) bundle a full database (like SQL Server Compact) with your application.

MVC 3 C# - Deployment and MYSQL Database

Visual Studio 2010 - C# - MVC3
I am completely new to ASP.Net and I have been working / practising making an MVC 3 application using C#. I have practised getting an MVC application online which makes use of no databases and was successful. My hosting supports .net 4 and it was a simple process of publishing the files and uploading to my FTP. I am making a new application which makes use of a database. I have set up a data connection in the server explorer and set up all my tables and relationships. Everything is currently working as intended and I can create, edit and delete entries from the database.
I am not really sure where to start with getting this online. My hosting offers no MSSQL databases so I am presuming I can use a MYSQL database? What is the process of changing my application to use a MYSQL database which is located on my remote hosting? Also I am making use of the default accounts where users can register and login, will I have to set up a database for this too?
Your host offers mysql hosting?
you will need the mysql .net connectors.
also check this next out for the asp.net membership, mvc uses
http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-asp-roles.html
You can use a local DB in your APP_DATA folder or you can connect to a remote DB. Please let me know if you need additional help in either of these two areas or if I have misunderstood your question. You may also want to encrypt your web.config file to secure your DB passwords better.
From our chat:
Try this stackoverflow.com/questions/…
SQL CE supports binary deployment, meaning your hosted doesn't have to have anything installed and you get SQL support, however no stored procedure support (if that matters to you here)
In addition you can install the SQL Compact Toolbox into Visual Studio
http://sqlcetoolbox.codeplex.com/
See: http://blogs.msdn.com/b/webdev/archive/2011/01/06/how-to-bin-deploy-sql-compact-edition-4-0-and-razor-web-projects.aspx

Database access on other machine

I'm working on a program that will work very nicely with a database structure and using mysql. I could easy do this with a common server and common database. However I'm looking for a way to have my client(s) use the program on an offline machine without having to install any database managing software.
Basically I want the installation to set up the necessary tables on their machine and have them fill in the database with information relevant to them. Before I start though I wanted to know if this was possible to connect to and manage a database through a C# application with out installing sql software.
You could consider using SQL Server Compact Edition.
SQLite is another option.
Both of these can be deployed with your application and need no separate configuration.
Yes. It is possible. How to do it exactly depends on the database connection approach you're using. For example, this approach shows how to use DataReaders. That's a very old approach. Modern approaches are recommended to use LINQ to SQL, which can be configured to access remotely by setting up a DataContext to point to an external resource.
Basically, wherever you can define a connection string to connect to a DB, you can make that string point locally or externally. An external resource must obviously be available through some URL in order to connect, of course.
You can not connect to a mysql database without installing mysql.
However you can use in process database like sqlite or Compact SQL. They are not traditional server, but rather a library that keeps the database in a local file.

Categories