.NET Embedded/Offline DB that works with EF - c#

I've been researching different solutions for an offline database.
Basically I have a desktop application and I would like it to communicate with a database, without requiring internet connection. So I am looking for a way to ship my app along with a database that the app can work with.
All my DB intercation will happen through Entity Framework, so I need a solution that is compatible with it. So far, I have always used SQL Server Express for my DB, but as far as I know that requires that SQL Server is installed on the user's machine, which is obviously not what I need.
My DB will not need to handle huge amounts of data. (Worst-case would be something around 100,000 - 1,000,000 rows of data in the DB).
From what I am reading I found that SQLite, and SQL Server CE and a feature of SQL Server called LocalDB might do the job for me. (SQL Server CE is no longer supported my Microsoft, so I am guessing its not a good idea)
I was wondering if I am on the right track here? Is this the way to go, or is there a way to embed my SQL Server Express into my app.

SQL Server Compact and SQLite can both run as embedded and work with EF (SQL Ce much better than SQLite)
LocalDB might also be an option, requires admin access to install (not during runtime)

Related

.NET report getting data from both MSSQL and Oracle

We are using SQL Server 2016 and Oracle 11g (in the process of upgrading to Oracle 12c) .
I'm not a .NET developer; therefore, examples will be very helpful.
Our developers are trying to combine data from both MSSSQL (in-house applications) and Oracle (ERP systems) to create a report in .NET (so just reading from both databases).
The developers are adamant they need to install Oracle client on the server hosting MSSQL.
From the security perspective (surface area exposure), we are encouraged to minimize surface area exposure as much as possible. And I found a possible way on this blog. And this blog that seems to suggest creating a function as connection string.
Questions:
Is there not an option in .NET (array, etc) to hold data from either MSSQL and / or Oracle in memory for comparison (using employee id) with another database?
Since it's only a read, is it an overkill to have full Oracle client installed on the server?
How are the experts here if you need to pull data from both DBs?
Thank you.
At some point a machine will have to have the Oracle client. I don't know of a way to connect to Oracle without it.
I can think of two ways to do this. You can link Oracle tables directly in SQLServer. I presume you can then use the SQLServer dialect to query the Oracle table. I'm sure there is a performance penalty for this, especially if joining across RDBMSes.
A second option is to have some sort of table on your SQLServer that has a copy of the Oracle data. Depending on how much data there is or whether or not you retain it, it could be faster than querying the linked table with a join. It could be a permanent table or a temp table. You'll still need to query the Oracle machine and this done as needed or on a schedule.
If you have very little data, you may not even need a table.
You could also have another machine that performs the query of the Oracle DB and moves the data to SQLServer. You wouldn't need the Oracle client on your SQLServer, but on that machine.
I'd look into building a windows service running on a different server from MSSQL server that would utilize the managed Oracle client to ETL data from Oracle to MSSQL server on a schedule which would allow your .NET report to access the report data from one location, your MSSQL server.

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.

Deploy database along with project

I need to create an application that does the following:
The application is going to be installed on multiple computers on the same network
There is going to be a computer that contains the database other computers will connect to that database. (So there is a server version of the software and a client version)
All the computers that have the application installed should be able to do CRUD (create, read,...) operations in the database.
Database will be small, that is it should be less than 1GB in size.
Problems that I have:
I don't know which database to use:
SQLite - From researching on the internet this seems like a great database. It is fast, very easy to deploy . The problem is that from researching I think it is not that good handling multiple connections. When I say multiple I mean 5 computers using the database simultaneously.
MySQL - I work with this database and I know it is great handling multiple connections. The problem with that database is that I don't know how I will be able to deploy that database. I am required to deploy a database when installing the software. I know that if I require the users to instal MySQL doing a separate installation that will work. Maybe there is a way of deploying MySQL when doploying a project in visual studio.
SQL Server Express - I believe this will be my best option. I have researched on the internet and I found out that it is possible to deploy a SQL Server Express database with a application. I believe it will be easy to figure out how to deploy such database with a project but it will be nice if someone can point me on the right direction on how to connect to that database remotely from a computer on the same network. The database will obviously be shared in the network in order to achieve this.
Microsoft Access Database - I never use this database. I know it can handle multiple connections. Maybe it is a good choice.
It will be nice if someone can point me on the right direction of how to be able to deploy a database when installing my application. Moreover how will I be able to connect to that database from a computer remotely on the same network. Since the database is small and it will just contain text I think that the best idea will be to keep the database on the internet but I cannot do that. The software is required to work without an internet connection.
EDIT
From looking at your answers it looks like I have to install SQL Server express or MySql on the server computer. The problem is that I am required to do one installation. Is there a way of deploying MySql or SQL Server Express when deploying my application. Perhaps I have to embed mysql in the application and make my application install it somehow. My boss want to be able to install the software without having a internet connection.
EDIT 2
I been thinking and this part will be very hard to implement. Do you guys have any ideas how QuickBooks implement their database? I guess I need something similar. When you install Quickbooks you perform just one installation. Quick-books handles pretty well simultaneous connections. Do they use their own database? Oracle? MySQL? I agree with all of you. It will be so easy to perform two installations. Also it will be cleaner. The software that I am creating is supposed to run on windows xp, and latter versions of windows.
If you want a dbms as your backend you are installing two things, It could look to the user like one thing, but I can tell you from bitter experience, that can be a lot of fun.
For instance to install 2005/ 2008 express, there are various prerequisites. Like a .net framework. Then there's patches and updates, then opening up the firewall(s), depends on set up. Different topology / os choices. Peer to peer, domain based, Active directory, Terminal Services, citrix.
So automagically installing without an internet connection, and using the installer for the db, is nigh on impossible, unless you have rigid control over the user environments.
Welcome to a world of hurt.
Oh did I mention permissions, shares, UAC, 32/64 bit (for sql server dmo and smo, maybe)
Do you want to block installs on "incompatible" environments.
Oh and what about upgrades. To the db, to your apps.
What if your client already has a server install and doesn't want to clutter up their kit with another...
and many many more.
And I bet you just can't wait to test all the potential combinations.
You haven't said what your target environments are going to be, so I can't say how many worms are in the tin, but its's very big time with plenty of room for lots of worms.
Ours is a long running legacy app, so we are pretty much snookered, I'd never willingly start with this design again though. Locally deployed web app would take a lot of the pain out of it.
Go back and scare the crap out of your boss.
I would recommend Sql Server Express installed on a server on your network.
Microsoft Access doesn't handle multiple simultaneous connections very well and is not very efficient when accessed from a remote machine.
You don't need to worry about deploying the database with your client application, you can install Sql Server Express directly on the server. (This only needs to be done once). You will need to configure Sql Server Express to accept remote connections after it is installed on the server.
SQLexpress supports multiple connections. So if you attach database on "server" computer you can than connect from clients same way as you would to local database.(provided those computers are in LAN or VPN).
Several articles on the Internet mention that SQLite is not that good handling multiple connections if all the connections are writing to the same database. I finally managed to deploy my application with SQL Server 2008 express. I also deployed my application with SQLite (downloaded the latest version for .NET framework 4). Since I plan to use this database just on a local network (LAN) I gave SQLite a try. I was impressed on how efficient SQLite was. I tested the Database by connecting with 4 computers symoltaniously and constantly writing data (inserts) to the database. No data was lost. When I did this with SQL express it was also very efficient and I could not tell a obvious difference. Maybe you get to see a real difference once there are 50 computers connected like on a web server for example.
Other nice things about SQLite are that it does not take time to deploy. Also there are no heavy services constantly running. I guess that SQLite is a better choice than SQL express. Moreover SQLexpress will only use 1 CPU and the database is limited to 2GB.
I am going to mist the Linq to SQL classes thought. They where very easy to implement with SQL Server Express. So in short I think that every database is good at something. And in this scenario I guess SQLite was a better option for me and for the users.
P.S.
I am interested in seeing how SQLite lattest version will hanle multiple connections compared to SQLexpress. I will try to test soon with more computers and each computer running multiple threads, each thread performing an insert in the database. maybe I,ll see a big difference with that scenario.

using MySQL with C#

I want to know if it is possible to use MySQL Engine without having to install WAMP Server. I'm developing an application that will require a database, so I was thinking of using MySQL instead of MS SQL or access. So I don't want to install the WAMP package yet I want to install the MySQL Engine, so if possible, please provide me with the download link for the MySQL and how to install and use (start/stop service).
You will need the runtime and the .net connector to make this happen. You also might find the workbench (gui tools to manage the server and run queries) to be helpful.
The runtime installs a service by default, which you can control on the commandline or via the windows service management console (services.msc).
This sounds to me a lot like you're thinking 'desktop application', where the MySQL database will be a simple local data store. If that's the case, MySQL is not a good choice.
MySQL is a server-class database engine. It's designed to run full time in the background as a service. This makes it overkill for a simple desktop app, and as a user I'd be mad if your simple desktop app required me to run the MySQL service.
For the kind of app I think you're building, you really want an in-process or desktop-class database. Good examples include SQLite, SQL Server Compact Edition (not Express), or even MS Access. Any of those would be a better option here than MySQL.
On the other hand, if I'm wrong and you're building a web app or an app that will be distributed to several computers that all share the same database, then MySQL is a perfectly fine choice and you should read #Femaref's answer.
If your database isn't going to be incredibly large you could go with SQL Compact. It comes with the .NET framework, and works well for smaller databases.

fast local database

i have a desktop application that talks soap to a server. the communication is very slow so i want to download a lot of the data up front and query from my local database. i wan this local data to persist after the application shuts down so what is the best way for doing this . . . are there any good products / examples to do this . . there are about 25 tables that i am caching.
SQLite is perfect for this. A couple years ago I wrote a "smart client" application where I maintained a local cache so that users could still use the application offline. I used SQLite and had no problems, it is very small, persists quickly, and most modern ORMs support it. (I was using NHibernate)
http://www.sqlite.org/
Berkeley DB is a good, standalone DB. You should also consider ESENT, which is built into windows. Here's a write-up by Ayende.
The H2 database might also meet your needs. Microsoft offers a compact edition of SQL Server: SQL Server Mobile Edition. If SQL Server and TSQL is your thing, this might be a good choice.
You could always use an Access DB, usually pretty simple to ingereate with in .NET app and doesn't require any server to be installed or configured on the client.
Consider using Firebird, I believe they have a ADO.NET extension too.
I would consider SQL Server Express or even SQL Server Compact Edition, which operates on individual database files, like Access does. Despite this, it's still SQL Server.
You could also consider Apache Derby, which is used in Sun's Glassfish Java EE server.

Categories