How do you design SQL database in Azure without diagrams? - c#

I had to move some of my databases from SQL Server hosted in my pc to Azure.
In order to import my DBs Azure demanded that I remove diagrams.
And in SQLServer explorer in VS2015 there's no possibility to create diagrams.
Diagrams helped me a lot! When you have 10+ tables in DB you could create more then one diagram, which reflects some part of subject area. And all changes in diagram reflected on DB itself, so consistency was maintained (I doubt it would, if I use third party tool for design/diagrams).
So... What's the common approach to database design, if using Azure?
Rely on third party tools? Keep everything in mind (impossible)?
Or, perhaps, I missed something, and diagrams are there?

Azure SQL Database doesn't support Database Diagrams as of yet. You have to rely on third party like dbForge Studio for generating these diagrams.
Another approach is to create a simple console application in C# and generate EDMX using Entity Framework, this would still suffice for graphical user interface.
Also you can use SQL Database Migration tool, which can get your Azure SQL Database to your local SQL Server and can generate schema diagrams.

Maybe This could help? https://alexandrebrisebois.wordpress.com/2013/10/26/create-database-diagrams-of-your-windows-azure-sql-databases/ It's a blog post by a friend of mine talking about just that... Hope it helps ... BTW did You install SSTD on VS? If nog that might already help too

You can now do this in the preview version of 2016 SSMS. google "SQL Server Management Studio preview" or try https://msdn.microsoft.com/en-us/library/mt238290.aspx

Related

Using a database in a Windows application

I am developing a Microsoft Kinect game (for Windows) using C# and I need a local database to store information about players and their progress as well as more detailed information on their points and accuracy. I have never used a database within a Windows application and I was looking for some advice on how to do so. I have been trying to use SQL Server because it lets me create a database within Visual Studio. I have been unable to find many resources on how to interact with the database from within the C# application.
I really know very little about SQL Server so I do not know if it is the right choice for what I need. Does anyone have a suggestion for what sort of database system to use? Can you point me in the direction of some good resources/examples on how to do what I need to do?
Thanks so much!
Edit: I should also mention that I do have experience working with SQL.
There are other, more portable, solutions such as SQLite and SQL Server Compact Edition which do not require a separate server installation and are more easily accessed and distributed from within a standalone desktop application.
The usage can be largely compared to an external SQL server and/or Linq to SQL so the actual implementation should not be that hard.
Some interesting links:
How to: Deploy a SQL Server Compact 4.0 Database with an Application
An Introduction to SQL Server Compact Edition
As mentioned in another comment, a simple serialized XML file might also be enough for your use. It's fast, easy and if you don't need to perform any actual database operations but simply save and load everything then it might be more efficient.
Look into using a SQLDatasource and relevant tutorials. This will give you an easy way to get up and running without an intimate knowledge of SQL. Once you have the datasource setup and 'bound' to your database, you can use this to connect your controls (grids,labels,textboxes ect.) to it.
Check this out:
http://www.youtube.com/watch?v=w34BDhDPEEQ
You don't want the fully fledged SQL Server. SQL Server Compact Edition is more appropriate, or there's also SQLite for a non-Microsoft option.
The easiest way to interact with a database from C# is Entity Framework, which ships with .NET 4.5 or is downloadable as a nuget package for .NET 3.5 and .NET 4.
A different, non-relational-database option would be DB4O.
You could use Entity Framework
var player = db.Players.Where(x => x.playerId = id);
var points = player.points;
points =+ 100;
db.SaveChanges();
You could also write CRUD operations against the tables if you don't want to use an ORM
Basicly you will have to make a database with a table, using the GUI of Visual Studio.
Then where necessary in the code, you will have to create a connection with the database using a connectionstring. Then you will have to insert an SQL command using the SQLCommand class and execute it. This requires some knowledge about the SQL syntax, but just search what kind of command you want specifically now and in time you will get the hang of it. Don't forget to close the connection to the database when you are ready with writing or reading data.
I hope this gives the main idea.
Edit: Oh and for this kind of database SQL Server Compact will be enough.

Use Sync Framework with SQL 2008 change tracking on both local and remote

What I want is to be able to use Microsoft Sync Framework to sync two SQL 2008 databases that both use the SQL 2008 change tracking feature. One will be a server and the other will be a local SQLExpress instance, using a hub & spoke model.
There are some hints that others have accomplished this - namely Syncing SQL Server 2008 Databases over HTTP using WCF & Sync Framework. However, that solution requires "SqlExpressClientSyncProvider available from MSF's codeplex project site as Client Sync Provider". This same SqlExpressClientSyncProvider is hinted at elsewhere too. However, it either no longer exists or is hiding really well from my attempts to find it.
Most of the links and suggestions I've come across in my searching end up pointing to the MSDN samples site which has several examples (such as this one http://code.msdn.microsoft.com/Database-SyncSQL-Server-a9752fac) which all demonstrate using the sync framework via custom change auditing - which adds a lot of visible overhead to the schema such as tombstone tables, triggers, etc. This is what I want to avoid.
I'd be happy with a link to the bits for the SqlExpressClientSyncProvider, however, I suspect that it is built for the MSF 1.0 way of doing things. If there is a "MSF 2.1" way to do this via the SqlProvider classes or something along those lines, that would be great.
SQL Server Change tracking is only supported in the older offline provider (SqlCeClientSyncProvider/DbServerSyncProvider) which is the same providers used by the Local Database Cache project item in Visual Studio.
the newer SqlSyncProvider/SqlCeSyncProvider uses a custom tracking mechanism and it will take a great amount of customization to get it to work with Sql Change Tracking short of writing your own custom provider.
the SqlExpressClientSyncProvider is a sample provider that has since been taken out by MS from the download site.
this link still has some bits of it though: http://www.8bit.rs/blog/2009/05/debugging-sql-express-client-sync-provider/

How to start with database?

i have just started using visual studio 2008.I am working on c#.
I want to add SQL database particularly LOCAL database (.sdf) to my project and want to use queries which will save data in database and fetch some data from database and which will display and will perform different function.
So, if any body can give me any small tutorial or link that what are various types of databases i can use along with visual studio and and how will i be able to use it.
Any general tutorial will do.
Thanks a lot.
Regards,
Don't use .sdf databases.
I've worked with it but it was confusing. I was not able to use WHERE statements....
Use SQLite instead.
That is THE Solution.
Download SQLite here
Another tutorial
I recommend you the use of SQLite
Not sure why Gergen was unable to perform where statements. One issue I had with Compact edition was that I couldn't create stored procs or views. I don't have much experience with SQL Lite, so I can't give an opinion on that.
If you are doing web based stuff (i.e., asp.net), I found the following series a good introduction to database stuff: Data Access Tutorials
As for what database to use, as long as there's a provider for it, working with it via ADO.NET (or entity framework, or whatever) should be similar. If you are just starting, I'd probably recommend staying with the Compact Edition since most examples/tutorials you'll see will involved SQL Server.
For simple Local SQL database stores, there are quite a few solutions. A good full comparison can be found on from Wikipedia
SQL Express 2008
Out of process, runs as a windows service, supports stored procedures and views and does pretty much everything SQL standard does with few limitations. 50MB install.
Ideal for anything but large SQL deployments.
Loads of how to guides for SQL Express
SQL Compact Edition 3.5 (.sdf files)
In process, the code for accessing the database runs within the same process as your application. Ideal for embedded systems (point of sale, ATM, in-car systems etc...). Microsoft's equivilent to SQLite. Very small install (easy to deploy with app).
Getting started guide for SQL Compact Edition and a load of HowTos to get you going
SQLite
The non-Microsoft answer to an in process database. Pretty much the same functionality as SQL Compact Edition apart from it's a smaller install (300kb for SQLite vs. 2MB for SQL Compact edition), it supports larger database files (32TB for SQLite vs. 4GB for SQL Compact edition).
SQLite getting started article
Connecting to Microsoft SQL Server 2008 from Microsoft Visual Studio 2005 and 2008
http://msdn.microsoft.com/en-us/library/s4yys16a(VS.71).aspx
I've never built anything using SQL Lite so I can't say much for it. I have, however, built several commercial applications using Compact Edition and haven't had any serious issues.
You can't batch commands with CE and the syntax is the same as Sql Server (with many missing features, but the most commonly used features are there and I've never had a problem without a work around of some sort).
I've really only used it as an "offline" database in an application for a company that dispatches repair technicians. The applications run on netbooks and download their data from a MySql database whenever mobile connectivity is available so they still have access to their work when they have no mobile coverage.
Due to it being so similar to SQL Server, Compact Edition would probably be an easier starting point. Since you're using a local database file you probably won't hit the 4GB limit (with very little pruning my mobile databases rarely exceed 20MB) - and if you ARE hitting that limit you may want to consider using a service based database (like Express) instead.

How can I generate database tables from C# in order to version control the database?

Currently, changes to the database are made through the SQL Server Management program. IF a table changes, sqlmetal is run to regenerate the linqtosql classes and development continues. However, this makes deployment a pain, as you have to go through and manually update the deployment database (and any other databases used in the development cycle). It would be nice if we could use C# to generate these changes, as it would help eliminate human error and have the added benefit of being able to keep the database structure in git. Right now, the only representation of the database is in the generated linqtosql classes.
I've been looking around for a nice library that can handle this sort of thing, but the main solutions seem to be: keep a sql generation script, or embed sql in C# classes that can be run to make changes to the database. Both of these seem to be very non-ideal situations, as you lose the nice strong-typing that C# provides. It seems like there should be a way to do this using pure C#.
I've seen hints of being able to do things like generate databases from POCOs using both the entity framework and linqtosql, but I'm having a hardtime finding specific examples of that being used. Additionally, I haven't been able to discover if those have a graceful (i.e. data preserving) way of handling changes to the database after the initial table generation.
Are there any projects out there that solve this problem?
There exist several tools that help you with schema (and data) migrations of your database: RikMigrations, Migrator.Net and Machine.Migrations. Hope that helps.
Wizardby looks also promising: It provides database independent DDL scripts and automated migrations between different versions of a schema.
VS2010 can operate version control on your database schema through a Database Project. There are other tools out there for DB development that offer version control, you'll need to search to find them and compare pricing.
I prefer to version using sql scripts. Works pretty well, is free, supports updates, easy to version, works well with traditional source control methods.
First,
Create your DB
Use the Database Publishing Wizard to publish the database as a .sql script
Add a version number to the script
Add to your solution
Check into source control.
As updates are made,
Script updates to the previous schema as .sql files
Add a version number to the script that is incremented from the previous version
Add to your solution
Check into source control.
It sounds like you need a tool like Migrator.NET to manage your database migrations. We use it with a call from our site start-up to migrate the database as needed for any particular version.
I have toyed with an idea for creating a cleaner interface and someday hope to get around to implementing it, but other priorities have pushed that back. For now we are using raw sql strings in our migrations because there isn't a sybase driver implementation (outside of a very ugly hack I have written to manage the versioning table).
Redgate software offers something that may be really useful for you. It's called SQL Packager and it does it's job pretty well.
Features:
Easy roll-out of database updates across your client base
Script and compress your schema and data accurately and quickly
Package any pre-existing SQL script as a .exe, or launch as a C# project
Simplify deployments and updates for SQL Server 2000, 2005 and 2008
They also offer SQL Source Control which also may be useful to keep things nice and easy.
As an addon to MadBoy, SQL Packager can also launch the package as a C# project.
Red-Gate's SQL Compare is excellent as well, and as some of the banners on SO indicates, there is new SQL Source Control available as well.
Then they have their SQL Comparison SDK.
The trick here is to rely on the database being the single source of truth for your Linq schema, not the generated classes.
We use Linq to SQL extensively in our dev shop, and work as follows:
1. Create your database (working copy) from version control (baseline).
2. Modify your database any which way you like.
3. Generate Linq to SQL classes from the (working) database.
4. Create patches to update your baseline database to your working copy.
5. Check in and share these patches with all developers.
For a very quick and easy way of generating baseline and working copy databases, try DBSourceTools. http://dbsourcetools.codeplex.com
Have fun.

C# and MySql integration

How well does C# integrate with MySQL ?
I am planning to write a small desktop application that connects to a Database and displays records. Is C# and MySQL a good combination ?
Should I use Java Swings and MySQL ?
Thanks in advance
Yes, it is. You can use MySQL .Net Connector as mentioned.
Or better, you use ORM ( such as NHIbernate) to abstract away the database vendor. I use NHibernate with MySQL in my C# application and it works well.
As Ralph Stevens suggested, you'd better go with SQL Server 2008 Express. Visual Studio 2008 integrates neatly with it and can generate Linq To Sql plumbing code right off the database. With a few clicks you are ready to handle the database in every way imaginable.
If you code ASP .NET, there is an added benefit: The mdf file that contains the actual database information can be stored in the App_Data folder and that goes with the project itself rather than the database engine. That comes in handly when you distribute the code to coworkers.
MySQL would work just as well with its .NET Connector but you will lose the visual benefits.
They integrate quite well. You can use ODBC, or better yet, the new MySQL .Net Connector.
May be this links be use full for you, was for me, when I started :)
windows-programming.suite101.com and
bitdaddys.com
How big is your database requirement? .NET works much better with SQL Server. SQL Server Express can go up to 4 Gigs of data and it's free. It meets the requirements of most small to medium apps. I suggest SQL Server Express.

Categories