ORMs that can generate classes from an existing database - c#

Except for Entity Framework, which ORMs can generate classes from an existing database?
I am looking to move away from Entity Framework because it is just too slow. I am wondering which ORMs out there are going to be the easiest to migrate a fairly complex WCF service to (from Entity Framework and an Existing Database).

Not sure if it will work for you, but I have migrated from EF to dapper with great results. As far as generating code, dapper doesn't do it, but using a tool like codesmith or t4 you can quickly get a lot of your run of the mill classes generated.
If performance is your top concern, youd have a hard time beating dapper.

Related

Need Advice: Switching from Linq to SQL to Entity Framework

I know the high-level differences between linq to sql and entity framework, however, I am hoping for advice from someone else who has already made the switch themselves, or has sufficient experience with both. Coming from a strong linq to sql background, as far as implementation and low-level details, are there any important things I need to know as I start coding my new data access layer project with entity framework?
I already created my edmx file (I chose the database-first approach), and everything just seems suspiciously identical to linq to sql so far. What would help me is a short list of items, like, in linq to sql, you do [this] [this way], but in entity framework, you'll want to do it [this way].
Sorry if this is a strange question, but any attempts at answers would be greatly appreciated. Thanks!
In new project between L2S and EF I suggest EF (consider Entity Framework version 4.0 or superior, DON'T use early EF releases).
While Linq to SQL is a class to table mapping EF 4 is a complete ORM (Object Relational Mapping) tool with different mapping scenarios.
With EF you have a lot of flexibility:
Database First approach
Model First approach
Code First approach
and a strong integration with LINQ Provider.
Unit testing with Linq2SQL is a nightmare.
With EF you have POCO (Plain Old CLR Object) classes out of the box. In L2S the entity class is tight coupled to the L2S namespace.
EF can help you also in Domain Driven Design scenarios.
Microsoft consider now EF the first database access method and it's the base for other services like RIA services or MVC database scaffolding.
LinqToSql is now the first database access methodology only in Windows Phone scenarios.
NH is far better... but again as EF is microsoft baby, it will grow as time goe

Migrating to Entity Framework custom ORM

We currently have a solution that was completely written by hand in ASP.NET and MVC.
There are a lot of ugly hacks and workarounds in the DAL currently and rather than expand on these hacks, I've managed to convince the suits that we need to migrate to an ORM of some sort.
With Entity Framework experience in the team, we've decided to go with the Entity Framework, however, I have a migration question for anyone who may have had an experience with this.
Would there be any performance issues if we were to migrate Entity-by-Entity until everything was migrated to EF? What possible roadblocks (other than the obvious of having to rewrite most of the BL) could we face? Should it literally be done Entity-by-Entity (in terms of, creating the models) or would there be issues creating the entity model and just changing the BL bit-by-bit.
I can't seem to find any documentation on the subject.. MSDN seems to just say "Yay Entity Framework is good, so migrating to it is good.".
Any advice would be appreciated.
PS: I did read this: Migrating from 'native' OODBMS to ORM (Entity Framework / SQL Server)
However as we've decided to go with EF instead of NHibernate, it didn't prove very useful.
It's good question and i have a answer from my prospective. It's about 'Yay Entity Framework is good, so migrating to it is good'
Now our team is working over big (very big) HR SaaS solution. From the beginning we decided to use:
EF 4.1
MySQL (that was requirement from client)
.NET MVC 3
Then time passed (near 3 weeks) we noticed next about EF: using Model first is not applicable and useful in our system in case of hard to support system in future when we need, for example, change a little bit db structure or make new relations between tables.
In this case we moved to EF Code First (with one generic repository for all db requests). That was the risk cause it's so new technology and there was no best practices or use cases on big solutions. As result we recived a lot of other headache:
ORM made a lot of db requests (cause of a lot of relations between tables). Fixed by .Include()
Dynamic Proxy for POCO objects - made a lot of troubles, cause in code first entities from db came not like requested entity type - like dynamic proxy type. So when we tried to serialize them and put to Memcached on deserialization we get the error that this entity no more available in current context. Fixed like this: http://msdn.microsoft.com/en-us/library/dd456853.aspx and this: http://blogs.dotnetkicks.com/dpeterson/2011/08/11/theres-a-proxy-in-my-boots-entity-framework-poco/
Stupid bag with Membership that sent a lot of unbelievable requests. Fixed by reviewing our work with Membership
Also we tried NHibernate to just compare performance. NHiberanate has the same :)
General info that you should know about EF:
If you want to attache 3rd part caching be ready for workaround. NHibernate have a native integration of this
There is no big different between EF and Nh performance, but Nh have a lot of hand work with mapping
Hope i answer to your questing and info is relevant for you.
ps> sorry for my English :)

Data access : Fluent Nhibernate vs ADO.NET vs Linq to Sql?

Creating My Windows Form Application and using ADO.Net as Data Access layer and
SQL server as my Back End with lots of SP's.
Do i still stick to ADO.NET or go to studying FnH or Linq to SQL? Which shall i choose? Or i still stick in ADO.NET?
Can you give me Recommended WebSites on EF or FluentNhibernate for kick of tutorials..
Thanks in Regards
It's really just up to you to pick one - they're all valid technologies.
If you're already familiar with the low-level ADO.NET constructs, and you don't feel like putting the time into learning a different methodology, you can stick with plain old ADO.NET - this is not going away anytime soon.
If you want to start off with a very simple ORM, I would suggest LINQ to SQL. However, Microsoft has basically left LINQ to SQL in the dust in favor of Entity Framework, so if your project has long-term maintenance concerns, LINQ to SQL may or may not be the best choice. It is a really nice, lightweight, easy-to-use framework though...
If you want to learn the latest MS data access technology, you could try Entity Framework. The initial setup is not too bad, but Entity Framework is a beast, so there might be a bit of a learning curve at some point, if you run into something that works differently than you expect, or you want to learn more. EF is fairly full-featured at this point, but it still lacks some of the functions offered by more mature data access technologies like NHibernate.
Finally, if you want to try something different than the Microsoft offerings, NHibernate is a great framework. You're not going to find the entity designers, property pages, wizards, hand-holding, and stuff like that, but that's almost the point of NHibnerate. In Fluent NHibernate, the primary focus can be on your domain code, and less on the database, which makes it very conducive to unit testing. Entity Framework has gotten better with persistence ignorance, but it still feels a bit heavy-weight compared to NHibernate.
In addition to these, there are several other solid data access technologies that you could look into, but I hope this gives you some info to start with.

Rapid ORM for Painless ASP.NET MVC Prototyping on SQL Server

What is a good ORM to use for rapid prototyping without the hurt?
I've used LINQ-to-SQL with great success, but I always end up building a whole repository layer around it (and everything that entails) so I don't have to put "Insert/Update" and mapping logic in my controllers. If I want to add a column, I have to write migrations and update interfaces and repositories.
I'd like something that just works. db4o is a good candidate, but I've always had gripes with the lack of proper data paging and the cringing primary key support. So let's narrow it down to a SQL-based solution that works with SQL Server.
Which ORM can build a relational SQL database with the least amount of configuration or code?
Entity Framework is quite nice and with the latest release you get some nice features like Code First and POCO entities.
I would look at Fluent NHibernate as it is really quick to pick up and the fluent configuration is nice.
Entity Framework / Linq2SQL have the shortest time to market. NHibernate is a little more complicated.
I'd go with NHibernate anyway. When things get more complicated, it gets harder slower if that makes any sense.

What is the preferred method of building extremely lightweight business object / DAL now that I have finished a simple database?

I have completed a simple database for a project. Only 6tables. Of the 6, one is a "lookup" table.
There is one "master" table that is the driver for the system. It is referenced as a foreign key by the other four tables.
Give that this step is completed. What is the FASTEST, EASIEST way to create POCOs/BizObjects that can load load the data and the child data.
Here are my CAVEATS.
I don't want to spend more than 30-60 minutes learning how?
There is very little biz logic needed in the POCOs. They will pretty much load data. Don't even really need to write back data.
I already know CSLA (up to version 3) but I feel that is overkill for this little project.
Nevertheless, I would love it if it ROOT objects could have collection classes that contain the CHILD objects as in CSLA...but again, without using CSLA.
Please give the answer for .NET 35 but also if I was restricted to only use .NET 20.
Ideally I could just point a tool at the database and the POCOs would be genn'ed.
FREE
Just curious what you guys use for this kind of scenario.
I understand that this question is subjective but I want to hear a variety of answers.
Seth
My choice would be linq-to-sql using sqlmetal to generate the code from the database.
Sqlmetal is a command line tool that generates classes for the database without customization. The advantage compared to the linq-to-sql designer is that you can easily rerun the tool to regenerate the classes if you have any changes to the database. Using the designer there is always a risk that the code isn't updated to match the database.
Use an ORM like nHibernate, SubSonic, Linq to SQL or Entity Framework.
They will all generate classes for you and a data layer.
The fastest to get up and running would be Linq to SQL, as it is built into VS 2008 (point to a SQL server, drag and drop, magic!).link text
For .NET 3.5, LINQ-to-SQL; drag the tables onto a data-context, job done. Actually any ORM would probably do, but LINQ-to-SQL is a very quick way of getting the job done using just the MS tools and VS IDE.
They aren't "pure" POCO done this way (they have L2S attributes etc), but it is easy. You can do pure POCO with L2S, but it takes a bit more effort.
With 2.0, NHibernate. But more work as unless you use additional tooling you'll have to write the classes and/or mapping files.

Categories

Resources