简体   繁体   中英

How to make a WPF Desktop application accessible over a network

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?

PS: 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:

图片

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM