i use recent versions of asp.net core, because want create set of web apis it. however, tutorials found focused on entity framework. can't use because have "legacy" database, code-first approach not option.
my idea use ado.net connections database, don't know if system.data.sqlclient
available in asp.net core project. found available when use .net framework project template still available in .net core project?
the existing sqlconnection
, other related connections still exists within system.data.sqlclient
namespace , should work expected using full framework or .net core.
you'll need add appropriate references , using statements include such through system.data.sqlclient
namespace seen below in project.json
file :
and call via syntax accustomed :
using(var connection = new sqlconnection("{your-connection-string}")) { // work here }
so long have valid connection string connect existing legacy database, should fine.
regarding orm usage
i found people using dapper, micro-orm replacement entity framework, apparenty more flexible. there advantages of using instead ado.net?
these orms (object-relational mappers) handy , powerful tools can more map existing database data specific classes , objects, can make them easier use (as opposed iterating through data reader, parsing each of rows , building each object manually).
as far performance goes, depends on going doing queries. ado.net fastest bare-bones connection database, in scenarios dapper can beat out. entity framework, while useful, trails behind in performance, because such large orm.
again - depends on doing, viable options.
Comments
Post a Comment