更新时间:2023-12-02 23:40:22
你要找的东西是一个
真的没有理由使事情过于复杂通过使用WCF(不是为这种东西而设计的)。 Web API可与owin等一起使用,以处理用户帐户的身份。
I have an application that access to a Sql Server database. I have a repository in a dll that can be used by the client and can connect directly to the database.
Another option is that the client connect to a WCF services and this service use the entity framework repository to connect to the database.
As is expected, if the client use EF to connect directly to the database, is faster than doing through WCF, so I am wondering if this second option is a good idea or not.
The adavantanges of to use EF directly:
Disavanteges:
An option it would be to have only a copy of the client in a network folder, so the clients run this copy, but this is not a very good, because if I connect from a computer with a slow internet connection (with a VPN) then it is very slow because it has to load in memory all the application (at least the exe and other dlls) and this is very slow. So the solution is to run a local copy of the application, but then I have the same problem, how to ensure the client runs the last version of the repository.
If I use WCF:
Disadvantages:
So my question is, which is the common way or the general way to connect the database. I always connect in the LAN or if I am out, with a VPN created with OpenVPN, son in pracice, I always connect inside the LAN.
About security concerns, by the moment I dont control the authorization, so any user of the aplication can do it averything. In the future, I could control thorugh WCF or if I use EF directly, perhaps with permissions in the database, control the access to the tables.
Thanks so much.
The thing you're looking for is a Web Api. There are even web api 2 controllers that you can add, which are a template api controller with some example methods to be used together with Entity framework.
There's really no reason to make things overcomplicated by using WCF (which isn't designed for this kind of stuff). Web API can be used together with owin etc. to take care of the identities of the useraccounts.