Ok so i know I'm fairly new to C# and MVC but I'm trying to use the code first approach of adding items to a database.
Now I have successfully created new entries to the database but when I go to SQL Server i cannot find the database or tables.
So my question is where is this data being stored as I can't see it in SQL Server like my other databases that I manually created?
My ConnectionString is:
Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-Testing-20140809020449.mdf;Initial Catalog=aspnet-Testing-20140809020449;Integrated Security=True
LocalDb is the new server-less version of SQL Server that has similar features as SQL Express. I would describe it as a just-in-time version of SQL Server that is only running when needed.
In order to connect to it usng SQL Server Management Studio, you need to connect using the following connection string (assming SQL Server Version 11/2014 may change to 12 or higher in future versions):
Then you'll have access to the database.
[project_dir]\App_Data\aspnet-Testing-20140809020449.mdf
Related
I have produced a small program that uses a database created in MS Access. I have created about 5 queries for the database to test it and everything is working fine. I want to learn something new, so I decided to improve my program by migrating DB to SQL Server, but I don't really know where to start from. I have installed MS SQL Server 2012 and looking for some tutorials/pointers for beginners. My initial goals are:
Convert MS Access database to SQL Server
I believe that the up-size wizard included in MS Access can be sufficient for the job. Am I right?
Connect my C# program to DB saved on SQL Server
I think that I should edit my connection string and replace OleDb with something else... What should it be?
I am not sure if the tool exists also for Sql Server 2012 but in 2008 R2 you have a menu entry in the Program Group for Sql Server called Data Import Export (32bit) (Translated from my localization, hope to be near at the exact thing) that could be used to port an MS Access Database to a SQL Server. Of course you need install Sql Server Management Studio to manage the fine details of your new database.
For the code part (connection string) you could continue to use OleDb changing only the connection string (see here at www.connectionstrings.com), but your best option is to change everything and use the classes in the namespace System.Data.SqlClient like SqlConnection instead of OleDbConnection, SqlCommand instead of OleDbCommand and so on....
I'm developing a WPF application, which connects MS SQL2008 database remotely.
The app communicates with the database by Linq-to-SQL. pretty handy.
However, because of the slow database server, I'm trying to use local database caching.
"VS2010 > Add Item > Local database cache" wizard could be a solution, but it uses DataSet and SQL Compact(*.sdf).
I found Linq-To-SQL cannot generate classes from the SQL COMPACT edition!
(when I drag tables, error pops up and says 'unsupported data provider')
So, is there any solution to use Linq-to-SQL with local database cache?
or is there any database sync method played with Linq-to-SQL?
If you still want to go the sql compact way, Lightspeed is a linq-to-sql provider that supports a variety of data-sources. it includes mssql compact.
http://www.mindscapehq.com/products/lightspeed
The free version is sufficient for most projects, with an 8 model/class limit.
Ive used it as a linq provider for MySql and Sql Compact before and it's been great.
You can see everything it supports and how it compares to other existing systems like it here:
http://www.mindscapehq.com/products/lightspeed/comparing-lightspeed
the Local Database Cache Wizard only supports SQL Ce on the client side. if you have SQL Express/SQL Server on the client side, you can use Sync Framework still.
see following samples/tutorials using Sync Framework:
Synchronizing SQL Server and SQL Express
Database Sync:SQL Server and SQL Express 2-Tier
nevermind if it mentions SQLExpress, the SQLSyncProvider referenced in the code should work against SQL Express,SQL Server, and SQL Azure
I'm writing windows application which will be used on one computer. I like to do with SQL server, retrieve data with stored procedures, and so...
My question is, what is the difference between SQL server database (in file) and standard db on SQL server, because I don't want to install SQL server on client's PC just for one app. Can be this SQL server DB used with stored procedures, or is there other way?
Thanks.
If you don't want to install a full SQL Server engine on the client machine you could use an embedded database such as SQL Server Compact or SQLite which are designed for those scenarios.
You may want to look at SQL Server Compact, SQL Server Express or something like SQLite. I don't think any of these really offers a way to run a database engine without installing something or requiring something else to be installed (e.g. you could use AttachDbFileName method with SQL Server but this relies on VS/Express to already be there).
I was using ADO.Net in my .Net projects from the past few years. Now I started using Linq2Sql and Entity Framework.
When using ADO.Net application my client should have SQL Server in their system to access the database file.
But some one has told me that Linq2Sql and Entity Framework doesn't need SQL Server on the client, it just need the .mdf file to access the database.
Because in LinqToSql we give the connection as the path of .mdf file
DataContext dc= new DataContext("path to database file");
Is it true?
Please explain me all the things.
I highly doubt that you can directly use ,mdf file without SQL Server because
Database transactions are not simply file reading and writing that can be done directly against .mdf file.
LINQ to SQL queries are first converted into SQL and then executed. Without SQL Server engine, how these SQL queries would be interpreted
It is not related with ADO.net or LINQ2SQL or EntityFramework. It is related with which Database Edition you are using. And I don't think you can use .mdf file without Installing SQL Database Server from any of above data access technology.
May be you are referring to SQL Compact Edition (.sdf). Which you can use without installing SQL Server. (You can also connect with ADO.net to .sdf database file)
myConnection = new SqlCeConnection("Data Source=\\Mobile\\Northwind.sdf;");
myConnection.Open();
[SQL Compact Edition]
You're thinking User Instances, replaced by LocalDB in SQL Server 2012. This has nothing to do specifically with Linq to SQL or Entity Framework. And all these options require installing SQL Server on the client machine.
Im implementing application in which there is local database which uses SQL CE. Each time app starts there has to be synchronization between local database and server database (to have new values in dictionary tables).
Problem is that mappings are different in sql ce and sql server 2008 when using entity framework.
Is it common problem ? is there any way to automate that ?
Do you know about any good pattern ?
thanks for help,
bye
You can use Merge replication, which supports (almost) all SQL Server 2008 datatypes.
Issues relating to EF seem to be unrelated, can you elaborate... You must create the model based on a SQL Compact database, you cannot use a model created against a SQL Server database with a SQL Compact database
Have you tried ADO.Net Synchronization framework? See here