How to use Linq-to-SQL with Oracle database - c#

I am trying to using Linq-to-SQL with an Oracle database. I had using .dbml file but its giving exception for Network Instance due to not available SQL Provider. So please guide me how can I use Linq-to-SQL with Oracle database.

Linq-to-SQL is a SQL Server only solution - it was designed by the C# team (not the database folks) only as a "proof-of-concept" for the LINQ capabilities.
If you need support for other databases - like Oracle - you need to use Entity Framework instead (which was created and still is being further developed by the ADO.NET/database team at Microsoft)

Related

Is there a way to do LINQ to SQL with MySQL for .NET Application?

I want to know if there's way to achieve LINQ to SQL today with MySQL database to generate a *dbml file?
I need the dbml file while running a MySQL database.I been going through a lot of old posts but didn't find the ideal solution.
I'm running .NET 4.7 with VS.
Linq-to-SQL was a "proof-of-concept" project for showing off the power of Linq and C# - but it only supports SQL Server and has no extensibility capabilities - and it's been long deprecated, too.
You should check out either Entity Framework which allows you to use Linq-to-Entities, or something like Dapper to access MySQL from .NET

What changes are needed to switch database from SQL Server to Oracle using Entity Framework?

I have developed a MVC web application using Entity Framework with SQL Server as backend. I have used a database-first approach.
Now my client wants to switch to an Oracle database. I am in the process of doing impact analysis of switching from SQL Server to Oracle database. My client believes that it is as simple as changing connection string.
My question is, considering the fact that the table name, table structure, relationships and attributes are all same with SQL Server database, what changes do I need to do in my project to switch from MS SQL to Oracle?
Do I need to create a new edmx file for Oracle database or do I only need to change the connection string and use the same context?
Also if in future this needs to be reversed, then is there a good practice or solution to support both the databases?
Thank you.
oracle has a 30 character limit for item (table, index, column) so if you are verbose in any of your naming you are going to have to rename a bunch of items.
i don't like using an edmx. it might be easier with code first models.

How to migrate linq to sql for sqlce to sqlite?

I have a project with SQL Server CE as the database using Linq-to-SQL.
How can I replace SQL Server CE with another DBMS? (preferably SQLite)
I looked around the net for some info but nothing about replacing an RDBMS in a Linq-to-SQL scenario.
Best regards and thanks in advance!
Salih Goncu
Editing to reflect the comments:
The name of the product is "SQL Server Compact Edition" if you want the full name, or if abbreviated form is preferred, then SQL CE, as the Microsoft SQL Server Compact Edition team prefers to use in their own blog. http://blogs.msdn.com/b/sqlservercompact/
Second, Linq to Sql is not specific to SQL Server only. It is supported by many different RDBMS, including SQLite. The annoying fact is, when you create your schema, a code behind is also generated and there are SQL statements auto-generated in that code behind which needs to be converted. Doing that manually is tedious.
My revised question is, "is there an easy way of doing this conversion process?"
Thank you very much.
Did you try to install this package to make linq work with sqlite?
https://www.nuget.org/packages/linq2db.SQLite/

Create an SQL database programmatically c#

Is it possible to create an SQLite database programmatically in C# - by coding.
I was using an XML to store information I needed in my application but it has gotten to the stage where the amount of data being read from the XML is such that the performance of the application is suffering.
As I understand it SQLite databases can be read from and added to faster using the provided System.data.Sqlite functionality.
Is this correct?
[edit]
In addition I should mention i'm doing all this in unity 3d with Monodevelop.
I believe you don't even need to explicitly create an SQLite database to work with it, just put its name in a connection string and it will be automatically created when you create a table in it.
you could use code-first feature in Entity framework: the 4.0 capable providers also add DeleteDatabase/CreateDatabase/DatabaseExists functionality.
more info at:
http://blogs.msdn.com/b/adonet/archive/2010/12/14/ef-feature-ctp5-code-first-walkthrough.aspx
Use SQL Server CE.
You can create a database file like this:
Create a SQL Server Compact Edition Database with C#
I'd use this because is "official" MS database. So it will work fine with MS technologies (Linq to SQL, Entity framework, etc.) It's also a very lightweight DB. Take into acount that there's also available SQL Server Express, but that's not such a lightweight database.
Code to create database:
string connectionString;
string fileName = “ArcaneCode.sdf”;
string password = “arcanecode”;
connectionString = string.Format(
“DataSource=\”{0}\”; Password=’{1}’”, fileName, password);
SqlCeEngine en = new SqlCeEngine(connectionString);
en.CreateDatabase();
Distributing it only requires copying a few small assemblies (for example the installer for SQL Server CE 2005 it's a 1.7Mb .msi file which results in 7 assemblies) Zero configuration. And there are versions which can be used with .NET framework 2.0, 3.0, 3.5, 4.0 (version SQL Server 2005 up to SQL CE 4.0).
If someone can't see the adavantage of being supported by MS, so that using it with C# and otherMS technologies, and having a good documentation on MSDN.
I suppose that I got downvotes because someone is allergic to MS. If not, let me know why.

Where to store application data

I'm building a C#/WPF job search tracking application to keep track of resumes submitted, interviews, followups, etc and am not sure of the best way to store the data. Where/how would YOU store the data? My first thought was XML to keep it simple, but it seems like I should "model" my data since there will be lots of related bits of information. Would SQLite be a better choice? Other recommendations?
Since I assume you want to query and update that data I would even suggest an ORM like Entity Framework - it's easy to get started and the basic stuff like querying and updating will be very straightforward if you have worked with LINQ before - saves you the hassle of writing your own SQL queries. This also will allow you to easily extend your model later on should you decide to do so.
Edit:
There are self-contained light-weight alternatives that would still allow you to use LINQ:
SQL Server Compact:
Microsoft SQL Server Compact is a free
SQL Server embedded database ideal for
building standalone and occasionally
connected applications for mobile
devices, desktops, and Web clients.
Here' an article that describes how to get LINQ to SQL to work on it. Apparently you can also use LINQ to Entities on it but there's quirks (such as design-time support) that you'll have to work around.
SQLLite:
SQLite is a software library that
implements a self-contained,
serverless, zero-configuration,
transactional SQL database engine.
SQLite is the most widely deployed SQL
database engine in the world.
There's a LINQ provider for it called DBLinq
As #Robert Harvey pointed out in his answer there's (almost) full support for EF since there's an ADO.NET provider for SQLLite:
Support for the ADO.NET 3.5 Entity
Framework
Supports nearly all the
entity framework functionality that
Sql Server supports, and passes 99% of
the tests in MS's EFQuerySamples demo
application.
Generally, you want to store the data from your application in a database. For WPF and C#, that database is usually SQL Server or SQL Server Express, because Visual Studio 2008 easily integrates with those.
Do not use XML for this. XML is not intended to be a large scale storage medium; the purpose of XML is to provide a common language for different computer systems to talk to each other.
SQL Server Express is usable on any Windows PC; you just need to deploy the redistributable, using a named instance. See also http://msdn.microsoft.com/en-us/library/dd981032(SQL.100).aspx. If it's a small application and you want to go simpler, you can use SQL Server Compact Edition, or SQLite with the ADO.NET provider.

Categories