I have been searching on it how to switch ORM using repository pattern, and i was not able to find "examples/sample codes" of it so i can study with that.
I believe my search keywords were wrong (ex. How to switch from EF to ADO.NET using Repo pattern and etc), thats why I can not find an article that talks about it.
Lets say we implement repository pattern with Entity Framework.
Is it repo pattern tightly coupled in Entity Framework? or
Do I need to create another Data Access Layer that talks for ADO.NET/or DAPPER/ Nhibernate?(for example)
Thanks in Advance.
I don't think you need to add any ORM layer in Repository pattern, after reading your question details, looks like you are already using Entity framework but Code first approach. ADO.NET is used to map your database table into your project using Database first approach.
So, if you want to add ADO.NET ORM in Repository pattern , here is the link which may help
If you dont' want to use ADO.NET ORM here is the example for it using EF (But not any ORM)
Repository pattern without any ORM
If you are looking for exact migration process unfortunately I wasn't able to find any exact solution for that.
Yes, currently i am using EF. But my question on my mind is what if I switch to EF to ADO.Net.
They say repository pattern helps you to abstract and able to switch orm later. I just want to test it out if my repository pattern is correct by switching EF to ADO.Net or Dapper or Nhibernate and etc with sample code and implementation without affecting the EntityFramework to enable me to switch back and forth to different orms/databases.
I am thinking (dont know if i am right but i believe not) to create another implementation for ADO.NET of the repositories because the only one will still the same is the repository interfaces . They (referirng to ado.net and ef) both inheriting to the same repositories but different implementation. I am thinking was AdoNETContext and EFContext. So my Controller will not be touched only the Injection and DAL if ever.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly