ASP.NET MVC developing using an ORM - asp.net-mvc-3

When developing with MVC with an ORM
I dont like the idea that the ORM will make changes in my DB.
My application is a data driven application and the DB is the the first thing i created.
Isn't that an overhead to maintain the data scheme both in the model and in the DB?
How do i manage it?
Any ORM that is more suitable to this kind of work method?

I dont like the idea that the ORM will make changes in my DB
ORM don't have to make any changes in your database structure. If you have existing database you can simply use it without requiring any automated changes.
Isn't that an overhead to maintain the data scheme both in the model and in the DB?
How do you want to present your data in MVC? Are you going to use classes representing your data from the database? If yes then you have a reason why ORM exists. ORM maps relational data from database to classes = it loads them for you and persists them for you (= you don't have to deal with database access and SQL). If you are going to use object oriented strongly typed approach then ORM will not be overhead for you.
If you are not going to use such approach you don't have to use MVC. Just use ASP.NET with SQL data sources or ASP.NET dynamic data.
Any ORM that is more suitable to this kind of work method?
You have no special method.
Almost every ORM has some support tools or extensions which allows you creating basic mapping and sometimes also classes from existing database. In EF you will simply add Entity Data model to your project and in wizard selects tables you want in your application.
Sure the last paragraph was simplified. Each ORM has learning curve and its specialties so it will not be so "simple".

For .NET 4 Entity Framework, the tooling let's you go both directions; generate a database from a model and generate a model from a database. These features give you flexibility when implementing your change management protocols. I'm not sure what options are available for NHibernate.
Entity Framework references:
http://msdn.microsoft.com/en-us/library/bb386876.aspx
http://msdn.microsoft.com/en-us/library/bb399249.aspx
http://www.simple-talk.com/dotnet/.net-framework/entity-framework-4460---learn-to-create-databases-from-the-model/
A Stackoverflow comparison of the two:
Deciding between NHibernate vs Entity Framework?

Related

Joomla MVC ORM that can handle many to many relation

It looks like Joomla MVC uses JTable as their ORM. Problem is that they can only handle one table and my application uses relational data.
Is it possible to use Joomla classes to map my Models to relational data or do I have to use a 3rd party for this (doctrine, propel)?
Not sure if this all makes sense because sometimes Joomla seems to use the JModel as a data provider (executing queries) and the JTable looks more like a model than JModel.

Cache solution for Dapper when using stored procedures (MSSQL)

I'm using Dapper mainly for calling stored procedures in the database MSSQL 2008 R2.I do not have classes that map to database tables. Most of the data ends up in IEnumerable <Dynamic> and is transmitted to the grid on the screen.
Is there a ready to use solution for data buffering that I could use? (I need to use it on the MVC).
The data in the database are both static and dynamic in nature.I use the repository model to access the data.
Dapper doesn't include any inbuilt data caching features (although it uses extensive caching internally for the meta-programming layer): it aims itself squarely at the ADO.NET stuff - however, you could use pretty much any off-the-shelf caching component, including the HTTP runtime cache (HttpContext.Current.Cache), or the newer ObjectCache etc implementations. Because these just take objects, it should work fine.
If you are using a distributed cache (maybe via app-fabric, redis, or memcached) then you'd need the data to be serializable. In that scenario, I would strongly suggest using formal POCO types for the binding, rather than the dynamic API. As an example, in-house we use dapper to populate POCOs that are annotated with protobuf-net markers for serialization, and stored via BookSleeve to redis. Which sounds more complicated than it actually is.

POCO entity generator or edmgen entityclassgeneration: Performance issues

I am working on a project where performance is a key factor for success. I need to decide whether to use POCO entity generator or not. I might use entityclassgeneration instead of the POCO but I'm not sure if performance may be affected.
Another thing I should consider is the fact of having to work with stored procedures. I'm not sure if using the POCO entity generator template will give me some problems later in the development phase. Specially with the stored procedures.
Any advice would be helpful about using POCO entity generator or entityclassgeneration. By the way, I'm using Entity Framework 5.0 and MySQL database.

Modelling MVC + JSP with UML

I am new to Java Server Pages (JSP) but I am pretty used to Unified Modeling Language (UML).
I want to start to develop a Web Application that uses the Design Pattern Model–view–controller (MVC).
For instance I want to build the adequate UML architecture for the example given on this MVC + JSP Tutorial.
This Tutorial builds a simple application and as the author describes, it is a "web application is a Coffee advisor, the user will input the type of Coffee and get back some advise"
By adequate UML architecture, I mean Sequence Diagrams, Class Diagram, Package Diagrams etc.
How should I proceed?
This question could seem out of topic because UML is unfortunately always associated to Model Driven Development.
I mean that if you use Persistence annotations in your class diagram which would generate the code including Hibernate annotation and then the database from the code then UML can deal with MVC and not only with MDD.
This is strange but I prefer MVC to MDD because this is more realistic and save a lot of time at coding and deployment level. This is also better if you need multiple iterations between deliveries and requirement changes.
You have many tools which allows ORM but I think only Omondo has investigated the UML with ORM at object level oppose to the other tools more MDD oriented. I mean generate a database from a model using code generation while Omondo is only using Hibernate annotations and then let Hibernate to create the database. I prefer to use UML and Hibernate and not MDD to generate my Database because when using MDD once you have generated your database you can not change the code manually. Everything should be done at model level. This is too much constraints and sometimes impossible. Omondo and Hibernate allows me to change my code as many times as needed.

How to Implement Database Independence with Entity Framework

I have used the Entity Framework to start a fairly simple sample project. In the project, I have created a new Entity Data Model from a SQL Server 2000 database. I am able to query the data using LINQ to Entities and display values on the screen.
I have an Oracle database with an extremely similar schema (I am trying to be exact but I do not know all the details of Oracle). I would like my project to be able to run on both the SQL Server and Oracle data stores with minimal effort. I was hoping that I could simply change the configuration string of my Entity Data Model and the Entity Framework would take care of the rest. However, it appears that will not work at seamlessly as I thought.
Has anyone done what I am trying to do? Again, I am trying to write an application that can query (and update) data from a SQL Server or Oracle database with minimal effort using the Entity Framework. The secondary goal is to not have to re-compile the application when switching back and forth between data stores. If I have to "Update Model from Database" that might be ok because I wouldn't have to recompile, but I'd prefer not to have to go this route. Does anyone know of any steps that might be necessary?
What is generally understood under the term "Persistence Ignorance" is that your entity classes are not being flooded with framework dependencies (important for N-tier scenarios). This is not the case right now, as entity classes must implement certain EF interfaces ("IPOCO"), as opposed to plain old CLR objects. As another poster has mentioned, there is a solution called Persistence Ignorance (POCO) Adapter for Entity Framework V1 for that, and EF V2 will support POCO out of the box.
But I think what you really had in mind was database independence. With one big configuration XML that includes storage model, conceptual model and the mapping between those two from which a typed ObjectContext will be generated at designtime, I also find it hard to image how to transparently support two databases.
What probably looks more promising is applying a database-independent ADO.NET provider like the one from DataDirect. DataDirect has also announced EF support for Q3/2008.
http://blogs.msdn.com/jkowalski/archive/2008/09/09/persistence-ignorance-poco-adapter-for-entity-framework-v1.aspx
The main problem is that the entity framework was not designed with persistence ignorance in mind. I would honestly look at using something other than entity framework.

Resources