Getting started with databases for UWP and WPF: Roadmap needed - c#

I know general, less specific questions aren't ideal. But I'm a beginner and are pretty confused about how I get started with databases for Windows 10 Universal Apps as well as WPF.
I'll try to make my main question more specific by asking the following.
What database is best for beginners/small projects to use in WPF, Console Apllication, and UWP projects? Or do I have to use different databases depending on the project?
How do I install, configure, and use said database (a small example or reference will suffice)?
Where does the EF (Entity Framework) fit into all this?
I tried installing EF for a UWP project, but things like using System.Data.Entity; couldn't be found. But there was no problem in a Console Application. How come?
Are there any good books, blogs, online courses etc. you can recommend to get up to speed on all this database stuff for .NET?
I have already started my education by taking this entity course on pluralsight, but it seems that learning about the Entity Framework doesn't necessarily teach me how to set up a database. At least not in this course.
I hope some of you more initiated people can help me out. As you can see, I'm running in circles (sure feels like that) and I hope you can push me in the right direction. A general brain dump on the subject would be more than a sufficient answer.
If I'm not making sense, or if this question just aren't good for SO, please let me know in the comments. I'll clarify and take action as needed.

What database is best for beginners/small projects to use in WPF, Console Apllication, and UWP projects? Or do I have to use different
databases depending on the project?
A MySQL database would be ideal, as this is a Windows project and would integrate best with any of those project types. However, for development, you can create a local database as an MDF file. This sort of database is particularly easy to set up and work with as it requires no additional database software or server.
How do I install said database?
Try following this walkthrough to setup a local database project in your solution. Once the database project is created, other projects in your solution can easily access it, as shown in this walkthrough. The second walkthrough applies to a Windows Forms application, but you could easily apply the same concepts to any other project type.
Where does the EF (Entity Framework) fit into all this?
Entity Framework provides functionality that makes it easier to interact with and automate actions related to a database, such as retrieving, deleting, or modifying database information. A more in-depth tutorial is provided here.
I tried installing EF for a UWP project, but things like using
System.Data.Entity; couldn't be found. But there was no problem in a
Console Application. How come?
This may be because your UWP project did not have a proper reference to the Entity Framework. You can add the Entity Framework to your project's references using NuGet or the Package Manager Console.
Are there any good books, blogs, online courses etc. you can recommend
to get up to speed on all this database stuff for .NET?
Microsoft has some good documentation for learning Entity Framework. This tutorial was the one I learned from.

Related

Building C# and SQL Server database dependant application

Let's say I need to create an application like a books library management system for example that has a front-end like Windows form/WPF and it stores information to database. How to approach making such a solution.
Do we need to create a database first with all tables in C# or is the other way.. SQL to C#?
How do people generally do this? Can someone point me to a sample free project or a book that does this to reinforce my understanding.
Both ways are possible. People usually only focus on one side and use a tool for the other.
Database first approach: Codesmith is an exemple of tool that'll generate C# files after you created the database.
Code first approach: Entity Framework is (an exemple) for the other way around, you write your model in C# and it will generate the database accordingly.
Now pointing you at one or the other would be a bit subjective and also not really match Stack Overflow spirit.

WCF with Entity Framework multiple tables

I am creating a WCF service which is using Entity Framework for communication with SQL 2012 server. I have 3 questions.
1. Is is possible to create the database from VS2013 like in MVC5 models?
3. From where I can reach a good information except codeproject since there, they work only with one table and no relations at all.
I am a bit confused since I was get use to work with MVC and there everything is quite clear to me. Here I made simple exmplate, but I created the DB first and then the WCF + EF and the test Web Form application.
edited to not violate requirements
That's too broad a question to answer easily but "Pro C# 5.0 and the .NET 4.5 Framework" by Andrew Troelson has several chapters dedicated to the Entity Framework, WCF, and working with them. That would be your best bet for a high quality "tutorial" of sorts. It's my go-to reference text for C# and .NET and so far it has proven extremely useful during my programming internship.

only WPF,WCF and ADO.net based .Net project while having DB as Sybase is it possible?

We are having 5 years old mini ERP applications LAN based (Intranet only) with us, written in ASP.net 2.0
Now Since requirement changes a lot and Workflow also changed a lot, we decided to rewrite it again from scratch using WPF,WCF and our own custom Data Access Layer.
As it is LAN based our organisations is having Windows only Systems , so We can install the client module on each system.We are planning to develop both (Browser Based HTTP) and WPF based (Desktop) client Modules.
So , basically what i want to know from you people is that
Is it possible to create a solution with WPF project template(for UI),WCF Project template(for Middleware) and custom Data Access Library(AS DataAccessLayer)?
Later on if needed we will give browser based HTML+jQuery UI also so can we reuse the code mentioned in 1# ?
Our client wants Sybase as DB so is it possible to make DAL through Sybase DB?
Dont treat it discussion type Question and Dont close it
I simply wants to know the solution as 3 answers to these 3 questions due to these strange requirement with us :)
The answer is that it is definitely possible to do all of this.
Creating a front-end in WPF, a middle tier in WCF and a custom Data Access layer will work out well for you. Here is some guidance on how to connect WPF and WCF: http://wcfguidanceforwpf.codeplex.com/
You can definitely replace the WPF front-end with a HTML+jQuery UI. Here is some code on how to make use of a WCF service through jQuery: link
C# can access Sybase just fine. See This
Adam,
Yes it possible to all three question.
The are frameworks such as Prism / Caliburn / MMVM Light which can help with you UI.
If you base you business logic behind a WEB Api (SOAP / REST), you should be able to use similar business logic for both.
The database providers for Sybase, but may want to consider using an ORM (Object Relation Mapper) (Nhibernate / Entity Framework)
Cheers
Iain
The first two questions are well covered by the other answers. For the Sybase portion of the question here is what you should know:
Whether you plan to use a straight ADO.NET data layer or an ORM, the required DLLs and configuration set up are applicable to both. If you plan to use NHibernate 3.0 with Sybase then you should review the information here because it must use the NHibernate 2.1.2 provided dialect. NHibernate 2.1.2 does work just fine out of the box with Sybase ASE version 12. For that version, configure NHibernate with this dialect & driver:
NHibernate.Dialect.SybaseAdoNet12Dialect
NHibernate.Driver.SybaseAdoNet12ClientDriver
The SqlAnywhere drivers are different I believe but for ASE the DLLs you'll need to reference are listed below. You can only get them from Sybase through their support program to comply with their licensing.
Lastly, the Sybase ADO.NET driver seems to be a thin layer over their unmanaged DLL and its usage and stability shows it. It is certainly finickier to configure than the other ADO.NET drivers I've worked with. For example, since Sybase isn't typically configured to support a Unicode character set you need to set/map the .NET string parameters to use AnsiString or AnsiStringFixedLength (or AseDbType.VarChar) as appropriate. What's even more bizarre is if you forget to do this, the driver will silently fail and just write a null value to the table column.
sbgse2.dll
Sybase.AdoNet2.AseClient.dll
sybcsi_certicom_fips26.dll
sybcsi_core26.dll
sybcsi_profiler26.dll
sybdrvado20.dll

Best practice/starter solution with EF 4 and POCO

I have been trawling the internet for some months now, looking for some solid (and simple) examples regarding creating a new ASP.NET MVC3 (orMVC2) web site, that could connect to SQL Server 2008, using POCOs and EF4.
I understand the concepts, but seeing as their are many different ways to do the same job i'm struggling to find a full start to finish example I can use as a foundation, for a small web project I want to do in these technologies. I have the luxury of no existing db schema, but do not want to use code-first EF4 approach, I would rather do the model in SQL Server and then import entities into EF4.
I have created a project using 'the full stack' videos, but then realized that is specific to code-first, so sort of scratching my head again now.
If anyone has any good URL's to share, or indeed code/sln files then that would be great. Alternatively, if someone had the spare time to create such a project for a small fee, (50USD), from my specification then I would be interested in that also. I apologies if such requests are not permitted on this forum.
I look forward to hearing your comments.
This music store tutorial uses EF4. Although it's code-first, it shows how to connect to an existing DB as opposed to a lot of tutorials that create the DB "on the fly".
Here's a good example on how to "code first" with an existing database schema.
http://weblogs.asp.net/scottgu/archive/2010/08/03/using-ef-code-first-with-an-existing-database.aspx

Alter SQLite DB structure when upgrading app

I would like to use the EntityFramework model to connect to an embedded SQLite database in my C# application. Everything works fine but as this is the first version of the software I expect future changes to have a cause changes to the structure of the database.
I am concerned since I do not know when a user would upgrade from ver.1 to say ver 2. how to alter the strucure of the embedded database and of course save the existing data.
Anybody else run into this issue, and how did you solve it ?
Thanks
I wrote a complete upgrade framework in C# to handle this type of problem. It served me well in a big client project and saved me tons of work in the process.
You can read about it Here. It is in the public domain so you can use it for your projects (including commercial projects) without paying anything :-)
If you have any specific questions I'll be happy to help.
I got an idea but an unsure if it is a correct approach:
write an small external tool to alter(upgrade) the database structure, and run this in the application installer.
What do you think about such an approach ?

Categories

Resources