I have to develop a desktop windows application in C#.Net 4.0 that will run in three different databases ie. MS Access 2007 onwards, Oracle 11G, and SQL Server 2008. Now I want to use Entity Framework in my application. Is this a best choice to use EF for my application ?
If yes, then how can I use entity framework for Access database?
Thanks in Advance.
You can use the EF with Microsoft Access using an Entity Framework provider for Microsoft Access.
You can find an EF provider for Access
https://github.com/bubibubi/JetEntityFrameworkProvider
See this answer. Ask yourself why you need Access, could you use SQL Express instead? If you absolutely need Access then it would seem EF is not the right choice in this instance.
Putting Access to one side for the moment, it's perfectly possible to change data providers with EF (particularly code-first) as EF abstracts a lot of the database goo away from your code; depending on the database design it could be as simple as changing the connection string dynamically. The practical implications of this really do depend on your database design and the nature and complexity of the application you are building. See this question for example, here's another example.
We use Dapper as our ORM with repositories when working with MS Access. It's fantastic.
Related
Microsoft provides two ways of working with cosmos dbs in C#/.NET.
One can either use Entity Framework(EF) Core, which makes use of the cosmos SDK behind the scenes and allows you to use EF with Cosmos.
This last point could be seen as positive or negative depending on if you want to use EF vs Dapper or whatever, but for my use case, I would prefer to use EF unless given a good reason not to.
Microsoft themselves has not made any statement I can find on which should be used or why. (I Assume this is a .NET Core project)
EF Core works only for SQL API of Cosmos DB as of now. So, If you are using other APIs, you cannot use EF Core.
Also, Take a look at other limitations of EF Core Azure Cosmos DB Provider Limitations at https://learn.microsoft.com/en-us/ef/core/providers/cosmos/limitations
We used Cosmos DB SDK which is quite flexible and the performance is also good.
After an experience with Cosmonaut package, EF Core and SDK I have to say that Ef Core is focused on relational mapping. Witch Document DB you need to focus on Json serialization. Ef Core model configuration feels cumbersome and limiting for document DB interaction - You have to configure things that just works while serializing. Both Cosmonaut and SDK allow focusing on serialization which in most cases just works. Cosmonaut is a convenient facade on top of SDK - but looks dead at the moment so I recommend SDK.
HI I have this MVC4 internet application that have to access to the postgres server. I'm lack of budget so cannot afford commercial ado.net driver for postgres server. I had a look on npgsql but unfortunately it does not support entity framework 5. So I was wondering is that possible to wrap ado.net connection string as ODBC? If it's possible? does it also possible to use entity framework with that? please give me some advice. Thank you
No you can't
You can get a detailed explanation there Why doesn't EntityFramework support ODBC
Under a 100$ you can get some nice commercial ADO.Net drivers. Personally I've used dotConnect (For SQLite) but probably that their ProgreSQL package must be as good. You should give it a look. Also they have a 200$ license that can do ODBC.
I heard that companies that use Java technologies, they used to build their own custom Framework that wraps Hibernate. However, is it really feasible for their .Net peers to do the same thing with NHibernate or Entity Framework?
This is almost always a horrible idea - I think Ayende sums it up best in this article. In general, you should consider NHibernate itself to be the "wrapper" around your data access - attempting to build an abstraction layer on top of it is probably going to be a losing proposition.
Actually, you should check out some of the articles on .NET Junkie's weblog. He wrote several great posts on how to deal with repositories, queries, commands and so on. We've been using these in a very large enterprise system where we switch between an in-memory dictionary, an in-memory SQLite database and a production environment using SQL Server or Oracle. Obviously, we use NHibernate for this.
I use the repository pattern and a separate project/dll to abstract away the data framework nhibernate / entity framework. this is a good starting point http://codebetter.com/petervanooijen/2008/04/04/wrapping-up-nhibernate-in-repositories/
I'm interested in using an object relational mapper for an existing system which is a ASP.NET client, ASP.NET Web Services middle layer, and with an Oracle back-end. All database access is done using stored procedures and no SQL is allowed in the web services. I've been investigating NHibernate, Telerik's OpenAccess ORM, and the Entity Framework. I titled this "segregated" because the database is pretty tightly controlled by the DBA's. They also control the database design and reworking the database for adequate normalization (for the object model) is pretty much out of the question. Also, allowing the tool to create any of the SQL is also out the question.
My question is: Given these constraints, which of these tools would allow the best integration for this sort of environment?
None at all.
You're not going to be using 99% of the functionality of an ORM by having everythign done in Stored Procedures.
Probably better to use a Micro ORM like ServiceStack.OrmLite, or Massive, etc...
But looking at any full fledge ORM like NH, LightSpeed, EF, is complete over-kill and will just create more complexity for 0 gain.
Implementing your data access with stored procedures entirely does not mean that you won't gain any value by using an ORM. It just means that you will probably not use some of its benefits.
As for the ORMs you have evaluated, you have probably noticed already that:
All of them support Database First approach, where you can just create your model after the database is already defined, so you won't have to interfere with the DBAs work in any way but to ask for credentials
Entity Framework and OpenAccess provide visual representation of your model out of the box, while NHibernate doesn't
OpenAccess and NHibernate support Oracle, while with Entity Framework using Oracle is not so straight forward
The stored procedures support in Entity Framework and OpenAccess is much more sophisticated than in NHibernate. In OpenAccess you can even map a stored procedure to more than one results set.
I hope that helps.
Let me get this right. Your constraints are:
You have to use an ORM
You cannot modify the database in any way.
You can only use stored procedures.
I think I agree with #Phill. A full blown ORM is overkill when you cannot use it's functionality.
BTW, I once worked on a system like this where the DBA's ruled the roost and mandated only procedures to access the data. Nightmare.
I want to develop ASP.NET MVC site but I am confused about the use of EF. While developing my database structure/tables will be changed frequently and also after going to the production if anything happened?
If EF not for ASP.NET MVC3 then I would use ....... ?
nHibernate
RavenDb
Don't bother with anything else, in my opinion.
nHibernate is a very mature and open source ORM that can use SQL Server to get data into/out of your ASP.NET MVC (and version) project(s). It is the most direct competitor to EF it terms of popular options in the ORM space.
If you like new and cutting edge technology, then give RavenDB a go. It is its own database and doesn't require an ORM. It just saves the class library objects straight to its own DB. Therefore, you don't have database schema migration issues, etc.
I would go for RavenDb IMO. I'm leaving EF because I'm just so sick of SQL Server and all the hoops and barriers to getting my domain models to work nicely with a traditional RDBMS. (And this is after working with SQL Server since '95) ...