POCO Support in the Entity Framework - c#

While the application I am developing at the moment is written in .net 4.0 against the beta, I have largely been ignoring POCO support in the Entity Framework because I didn't need it. I'm starting to realize, however, that POCO support would be useful in my project. However, Google searches on POCO in the EF yield a lot of results about it "coming in the future" and "sneak peeks."
With the .net 4.0 framework in a Go Live license now, I know that POCO support must be largely implemented. Can anyone point me to a good resource for getting my feet wet on how it all works?

Julie Lerman has several blog entries on EF 4 POCO.
http://www.google.com/search?q=julie+lerman+poco

Another source for information (besides Julie Lerman's blog) is the ADO.NET team's blog, e.g:
http://blogs.msdn.com/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://blogs.msdn.com/adonet/archive/tags/Entity+Framework/default.aspx

Related

WCF with Entity Framework multiple tables

I am creating a WCF service which is using Entity Framework for communication with SQL 2012 server. I have 3 questions.
1. Is is possible to create the database from VS2013 like in MVC5 models?
3. From where I can reach a good information except codeproject since there, they work only with one table and no relations at all.
I am a bit confused since I was get use to work with MVC and there everything is quite clear to me. Here I made simple exmplate, but I created the DB first and then the WCF + EF and the test Web Form application.
edited to not violate requirements
That's too broad a question to answer easily but "Pro C# 5.0 and the .NET 4.5 Framework" by Andrew Troelson has several chapters dedicated to the Entity Framework, WCF, and working with them. That would be your best bet for a high quality "tutorial" of sorts. It's my go-to reference text for C# and .NET and so far it has proven extremely useful during my programming internship.

Switching from entity framework model first to code first

I'm working on a project using entity framework 6. At the start of the project I was a beginner with EF and choose to build with EF model first.
Now the model is quite big and I’m thinking about performance and ease to change the model without dropping the databases every time.
I thinking about switching to code first.
Given that model first has already generated all the classes I need and context, I don't think it's that difficult to switch to code first.
Nevertheless I would like to know what would be the best way to do that and if there will be real advantage in term of performance and ease of model modification.
Thanks for your help,
EF 6.1 tooling now allows creating a Code First model from the database. Here is a short video and a walkthrough showing the functionality. You can download the latest EF tooling from the download center.
The code created by EDMX is not same as Fluent API although it is closed to Data Annotations.
If you would like to work with Fluent API, you can use Entity Framework Power Tools Beta 4 to generate to Fluent API from Database.

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

Entity Framework 4.1 reverse engineering code-only

I am using Entity Framework 4.1 and want to take advantage of their code-only approach. In the video located at http://channel9.msdn.com/Events/TechEd/Europe/2010/DEV212 starting at 35:00 minutes in they show a tool that reverse engineers their POCOs from their existing database. I want to do this as I have an existing database. I have installed EF 4.1 and I can create POCO entities just fine but I can't seem to find the tool they used to create POCOs from the existing database. Was this tool not released with 4.1?
Thanks in advance.
The tool is called EF Power Tools CTP1.
If your database is SQL Server, or SQL CE 4.0 then you can use the "Entity Framework Reverse POCO Generator" available at visualstudiogallery.msdn.microsoft.com
Update:
This answer is no longer relevant as EF 5+ is completely full-featured with code-first migration tools.
I had abandoned code-first for a while because it did not appear to be as full-featured as I had hoped. Recently I had some time to play with EF 4.1 a little more and examine it in more detail. All I really believe they are lacking now is a data/schema migration ability. This dropping and recreating of the database is not very ideal.
In my examination I found that the tool I am asking for in this question was indeed shipped with EF 4.1. It is a code generation template called "ADO.NET DbContext Generator". It can be found by opening up your existing EDMX file, right-clicking your design surface, and selecting "Add Code Generation Item".

NHibernate 3 and MySQL setup tutorial

Since I have given up on using the entity framework 4 as my ORM (getting it to work with MySQL and mapping table/field names like this_table/this_field to object naming like ThisTable/ThisField is POCO) I am now looking at NHibernate as it seems the the next big well know ORM for C# that probably with not die off any time soon. I am trying to lookup some tutorials and a lot of them in the configuration section have 2-2 in it and was wondering if those configuration would work with NHibernate 3? I am just curious if the 2-2 refers to the version of NHibernate or something different.
I assume you're referring to this:
urn:nhibernate-mapping-2.2
as often seen seen in the mappings. That's not the version of NHibernate, it's the version of the XML schema. The previous stable version of NHibernate was 2.1.2, and as far as I can tell there hasn't yet been a 2.2 (although in the future there might yet be one -- as I understand it, NH 3 targets .NET 3.5 and I'd imagine there are a lot of people who can't upgrade yet).

Categories

Resources