Using Entity Framework or Micro ORM with Orchard - entity-framework

I recently discovered Orchard used by a company where I'm going to work. This CMS is very well designed and you can do a lot of customizations.
However, I don't found any examples explaining how to create a set of tables outside of Orchard and then doing CRUD operations with these tables using a Micro ORM like NPoco or with a more SQL abstract tool like Entity Framework.
I don't want to use the migration engine of Orchard in the futur to change these tables because I already have my own homemade engine. In other words, these tables will completely be driven by my engine.
In the same way, it would be nice to have examples of how to inject dependencies of these components. Dependencies are SqlConnection or Context.
Thank you.

I haven't used Orchard too much, but the documentation indicates it is using NHibernate, so I would recommend stick with it to access the tables you created with your own db migration engine.

Related

Is it feasible to build company specific framework that wraps NHibernate?

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/

Object Relational Models (ORM) in a segregated environment

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.

Does webmatrix Database class uses ADO.Net internally?

Is Database class just a wrapper for ADO.NET which makes use of db simpler ? What's its limits ?
Yes - the Database Helper is a wrapper around ADO.NET. It is designed to minimize the code that a beginner needs to get started with querying databases, similar to how its done in PHP. Its limits depend on your point of view. As someone who is just starting to learn web development and databases, you might think that the helper is a stroke of genius. As a professional developer, you might not like the fact that it returns dynamic types or that it doesn't prevent people dynamically constructing their SQL and potentially opening up their application to SQL injection attacks.

What alternatives are there for Entity Framework in ASP.NET MVC3

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) ...

Which .NET frameworks allow you to create Business Entities first, then Database

Do any .NET frameworks allow you to create Business Entities first then Database.
In other words allow you to use DDD / Persistence Ignorance method of backing into the database later. Any tools that allow the Models/Classes you have written to generate the SQL DDL and migration scripts.
Feel free to rework my verbiage, and make it a better question.
NHibernate supports domain-driven design, persistence ignorance, and automated data-model generation.
Eco from CapableObjects does what you are asking for and much more. There is a bit of learning curve, but the productivity gain is amazing. Not in any way related with the company btw - just a very happy customer.
You may opt for Castle ActiveRecord which hides the complexity of NHibernate and can create the schema from business entities with various options like creating a schema file and creating the database entities directly.
DataObjects.Net is designed to support exactly this pattern.