How to make a WPF Desktop application accessible over a network

c# desktop-application entity-framework-6 network-programming wpf

Question

I am designing a WPF application that connects to a MS SQL Server database using Entity Framework.

The application reads data from a Excel file and saves the records to the database. Now the next requirement has come that this application should be accessible to multiple users at the same time (company network) so that all users can see the data in database and query/update it whenever required.

What I am thinking is, all I need to do is just put the database on a central machine which should be on the company's internal network and my application should connect to that database and allow users to perform the operations.

What changes do I require to this current connection string?

<connectionStrings>
    <add name="TPMSContext" connectionString="metadata=res://*/TPMSModel.csdl|res://*/TPMSModel.ssdl|res://*/TPMSModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Test-DELL;initial catalog=TPMS;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

And what are other changes that I need to implement/keep in mind for my application to work for multiple users simultaneously?

P.S: My application is "ANY CPU" with targeted framework as 4.5. Right now its Desktop based but in future we might make it web based, but for now we just want it to be Desktop based as it is.

Update

This is the view of my solution explorer. TMPS is my Main application. TPMS.Data contains my business logic and methods that provides interaction with the database though Entity Framework. TPMS.Entities has the database tables as entity classes:

Image

1
1
11/17/2019 12:36:27 PM

Accepted Answer

This approach is called 3-tier architecture. You can implement it by WCF TCP/IP hosted on the window. You will host your Database interaction business logic on other server machine and client will consume these APIs on the other machine.

You need the flowing:

  • Create a service(Window) using WCF.
  • Host it.
  • Generate a proxy (interface or contract).
  • Distribute this proxy to clients application who needs to call and use this APIs.

You can create architecture of your application like below:

  • Deployed on the server machine:

    a) Data base Access layer (Interact with database). b) Business Logic Layer (It will methods of Data base Access layer). c) Service layer (Create WCF Services and call business logic methods here). d) Host these into server machine.

  • Client Machine - a) Create proxy class by using .svcutil tool b) use this proxy class to client machine for consuming services (APIs)

Reference:

Host a WCF Service

1
6/19/2015 2:52:57 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow