You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/apps/develop/data-access/mysql-database.md
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
---
2
2
title: Use a MySQL database in a Windows app
3
3
description: Learn how to connect to a MySQL database from your Windows app, and test your connection using sample code.
4
-
ms.date: 08/01/2024
4
+
ms.date: 01/23/2025
5
+
ms.collection: ce-skilling-ai-copilot
6
+
ms.custom: copilot-scenario-highlight
5
7
ms.topic: how-to
6
8
keywords: windows, windows app sdk, MySQL, database, uwp, wpf, winforms, windows forms, winui
7
9
ms.localizationpriority: medium
@@ -21,6 +23,9 @@ This example can be used with any WPF, Windows Forms, WinUI 3, and UWP project t
21
23
22
24
This will allow you to programmatically access MySQL databases.
23
25
26
+
> [!NOTE]
27
+
> [MySQL Connector/NET](https://dev.mysql.com/downloads/connector/net/) version 6.4.4 or later is required to use the `MySql.Data` package with Windows authentication.
28
+
24
29
## Test your connection using sample code
25
30
26
31
The following is an example of connecting to and reading from a remote MySQL database. Note that the server address and database name will need to be customized.
@@ -46,8 +51,19 @@ using (var mySqlCn = new MySqlConnection(M_str_sqlcon))
46
51
> [!IMPORTANT]
47
52
> In production applications, connection information should be stored securely in app configuration (see [**Adding Azure App Configuration by using Visual Studio Connected Services**](/visualstudio/azure/vs-azure-tools-connected-services-app-configuration)). Connection strings and other secrets should not be hard-coded.
48
53
49
-
> [!NOTE]
50
-
> [MySQL Connector/NET](https://dev.mysql.com/downloads/connector/net/) version 6.4.4 or later is required to use the `MySql.Data` package with Windows authentication.
54
+
## Building a connection string with GitHub Copilot
55
+
56
+
You can use GitHub Copilot to build the connection string for your MySQL database. You can customize the prompt to create a connection string per your requirements.
57
+
58
+
The following text shows an example prompt for Copilot Chat that generates a connection string similar to the one shown in the previous code snippet:
59
+
60
+
```copilot-prompt
61
+
Show me how to create a MySQL connection string to a server named myServerAddress and a database called myDatabase. Use Windows authentication.
62
+
```
63
+
64
+
GitHub Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs).
65
+
66
+
Learn more about [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) and [GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview).
Copy file name to clipboardExpand all lines: hub/apps/windows-dotnet-maui/index.md
+9-7Lines changed: 9 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
1
---
2
2
title: Build Windows apps with .NET MAUI
3
3
description: Learn about .NET MAUI, benefits it provides to Windows developers, and how take your Windows apps cross-platform.
4
-
ms.topic: article
5
-
ms.date: 05/09/2024
4
+
ms.topic: concept-article
5
+
ms.date: 01/23/2025
6
6
keywords: windows win32, desktop development, Windows App SDK, .net maui
7
7
ms.localizationpriority: medium
8
+
#Customer intent: As a Windows developer, I want to learn about .NET MAUI, the benefits it provides to Windows developers, and how to take my Windows apps cross-platform.
8
9
---
9
10
10
11
# Build Windows apps with .NET MAUI
@@ -28,6 +29,9 @@ If you are planning to build a new app for Windows and want to target additional
28
29
-**Native Controls**: .NET MAUI does not currently support using Windows App SDK controls. If you have existing controls from other Windows App SDK projects you intend to re-use or rely on 3rd Party or open source controls, you will need to find alternatives for .NET MAUI projects.
29
30
-**Closer to Windows**: When writing .NET MAUI apps, it outputs a Windows App SDK app, but there is some translation to get from your code to the native Windows app. With Windows App SDK, you are eliminating that translation step and are less likely to encounter issues with styles, API compatibility, or layout.
30
31
32
+
> [!TIP]
33
+
> Are you still deciding between .NET MAUI, WinUI, and other UI framework options? Check out the [Windows developer FAQ](../get-started/windows-developer-faq.yml) to learn about the different options for building native Windows apps. Then go watch the **Windows Dev Chat** episode on **Choosing your ideal dev platform**. The segment about [.NET MAUI](https://www.youtube.com/watch?v=4PJBJ8GICjM&list=PLI_J2v67C23bxTffW4XewbUEAOfSVZkrk&index=2&t=2193s) hosted by Beth Massi walks through examples and reasons for choosing .NET MAUI for your next app.
34
+
31
35
## .NET MAUI resources for Windows developers
32
36
33
37
### .NET MAUI documentation
@@ -45,7 +49,7 @@ This [one-day live stream](https://www.youtube.com/playlist?list=PLdo4fOcmZ0oWeP
45
49
### .NET MAUI blog posts
46
50
47
51
-[5 .NET MAUI Features for Building Great Desktop Apps](https://devblogs.microsoft.com/dotnet/5-dotnet-maui-desktop-features/)
48
-
-[Build Your Own Podcast App with .NET 7, Blazor, and .NET MAUI](https://devblogs.microsoft.com/dotnet/build-your-own-podcast-app-with-dotnet-blazor-and-dotnet-maui/)
52
+
-[Build Your Own Podcast App with .NET, Blazor, and .NET MAUI](https://devblogs.microsoft.com/dotnet/build-your-own-podcast-app-with-dotnet-blazor-and-dotnet-maui/)
49
53
50
54
### GitHub
51
55
@@ -82,12 +86,10 @@ If you haven't enabled development mode on your PC, see [Enable your device for
82
86
83
87
Check out a walk-through of [creating your first .NET MAUI app on Windows](./walkthrough-first-app.md).
description: Get hands-on with .NET MAUI by building your first cross-platform app on Windows.
4
-
ms.topic: article
5
-
ms.date: 08/15/2022
4
+
ms.topic: how-to
5
+
ms.date: 01/23/2025
6
6
keywords: windows win32, desktop development, Windows App SDK, .net maui
7
7
ms.localizationpriority: medium
8
+
#Customer intent: As a Windows developer, I want to learn how to create and run my first .NET MAUI app for Windows in Visual Studio.
8
9
---
9
10
10
11
# Build your first .NET MAUI app for Windows
@@ -23,29 +24,29 @@ If you haven't already set up your environment for .NET MAUI development, please
23
24
24
25
1. Launch Visual Studio, and in the start window click **Create a new project** to create a new project:
25
26
26
-

27
+

27
28
28
-
2. In the **Create a new project** window, select **MAUI** in the All project types drop-down, select the **.NET MAUI App** template, and click the **Next** button:
29
+
1. In the **Create a new project** window, select **MAUI** in the All project types drop-down, select the **.NET MAUI App** template, and click the **Next** button:
3. In the **Configure your new project** window, give your project a name, choose a location for it, and click the **Next** button:
33
+
1. In the **Configure your new project** window, give your project a name, choose a location for it, and click the **Next** button:
33
34
34
-

35
+

35
36
36
-
4. In the **Additional information** window, click the **Create** button:
37
+
1. In the **Additional information** window, click the **Create** button:
37
38
38
-

39
+

39
40
40
-
5. Wait for the project to be created, and for its dependencies to be restored:
41
+
1. Wait for the project to be created, and for its dependencies to be restored:
41
42
42
-

43
+

43
44
44
-
6. In the Visual Studio toolbar, press the Windows Machine button to build and run the app.
45
+
1. In the Visual Studio toolbar, press the Windows Machine button to build and run the app.
45
46
46
-
7. In the running app, press the **Click me** button several times and observe that the count of the number of button clicks is incremented:
47
+
1. In the running app, press the **Click me** button several times and observe that the count of the number of button clicks is incremented:
47
48
48
-

49
+

49
50
50
51
You just ran your first .NET MAUI app on Windows. In the next section, you'll learn how to add data binding and messaging features from the **MVVM Toolkit** to your app.
51
52
@@ -59,116 +60,114 @@ Now that you have your first .NET MAUI app running on Windows, let's add some MV
59
60
60
61
1. Right-click the project in **Solution Explorer** and select **Manage NuGet Packages...** from the context menu.
61
62
62
-
2. In the **NuGet Package Manager** window, select the **Browse** tab and search for **CommunityToolkit.MVVM**:
63
+
1. In the **NuGet Package Manager** window, select the **Browse** tab and search for **CommunityToolkit.MVVM**:
7. The `MainViewModel` class will be the data binding target for the `MainPage`. Update it to inherit from `ObservableObject` in the `CommunityToolkit.Mvvm.ComponentModel` namespace This will also require updating the class to be `public` and `partial`.
77
+
1. The `MainViewModel` class will be the data binding target for the `MainPage`. Update it to inherit from `ObservableObject` in the `CommunityToolkit.Mvvm.ComponentModel` namespace This will also require updating the class to be `public` and `partial`.
77
78
78
-
8. The `MainViewModel` class will contain the following code. The `CountChangedMessage` record defines a message that is sent each time the Click me button is clicked, notifying the view of the change. The [ObservableProperty](/dotnet/communitytoolkit/mvvm/generators/observableproperty) and [RelayCommand](/dotnet/communitytoolkit/mvvm/generators/relaycommand) attributes added to the `message` and `IncrementCounter` members are source generators provided by the MVVM Toolkit to create the MVVM boilerplate code for `INotifyPropertyChanged` and `IRelayCommand` implementations. The `IncrementCounter` method's implementation contains the logic from `OnCounterClicked` in MainPage.xaml.cs, with a change to send a message with the new counter message. We will be removing that code-behind code later.
79
+
1. The `MainViewModel` class will contain the following code. The `CountChangedMessage` record defines a message that is sent each time the Click me button is clicked, notifying the view of the change. The [ObservableProperty](/dotnet/communitytoolkit/mvvm/generators/observableproperty) and [RelayCommand](/dotnet/communitytoolkit/mvvm/generators/relaycommand) attributes added to the `message` and `IncrementCounter` members are source generators provided by the MVVM Toolkit to create the MVVM boilerplate code for `INotifyPropertyChanged` and `IRelayCommand` implementations. The `IncrementCounter` method's implementation contains the logic from `OnCounterClicked` in MainPage.xaml.cs, with a change to send a message with the new counter message. We will be removing that code-behind code later.
10. Add the following code to the `MainPage` constructor after the call to `InitializeComponenent()`. This code will receive the message sent by `IncrementCounter()` in the `MainViewModel` and will update the `CounterBtn.Text` property with the new message and announce the new text with the `SemanticScreenReader`:
14. Update the `Button` on `MainPage` to use a `Command` instead of handling the `Clicked` event. The command will bind to the `IncrementCounterCommand` public property that is generated by the MVVM Toolkit's source generators:
16. While the project is running, try updating the "Hello, World!" message in the first Label to read "Hello, Windows!" in **MainPage.xaml**. Save the file and notice that [XAML Hot Reload](/dotnet/maui/xaml/hot-reload) updates the UI while the app is still running:
Learn to build an app that displays [Microsoft Graph](/graph/) data for a user by leveraging the [Graph SDK](/graph/sdks/sdks-overview) in a [.NET MAUI for Windows tutorial](./tutorial-graph-api.md).
167
+
Learntobuildanappthatdisplays [MicrosoftGraph](/graph/) datafor a user by leveraging the [Graph SDK](/graph/sdks/sdks-overview) ina [.NETMAUIforWindowstutorial](tutorial-graph-api.md).
0 commit comments