This post focuses on using the Entity Framework 4.1 RC Fluent API with an existing database. When I say an existing database, what I really mean is that you're not letting EF Code First auto generate the database for you. So it could be that you like to create your entities and then manually craft the database. Or you may have a separate team of developers who like to control and manage the database. This article refers to the fluent API which is part of the Code First approach to the using the Entity Framework. Code First can create the database for you based on your entities and entity relationships, but as I mention above you may not want Code First to do this. Using EF Code First in this way is seen a core aspect of Code First by the EF team at Microsoft. So far I have to say I really like this approach, no large xml files to worry about, instead it's all controlled through code. Additionally the entities are plain old CLR objects (POCO). This means that your entities (and thus the assembly they are contained in) don't need to reference the Entity Framework. The following example shows how to create an entity model, then manually create your database and then map those entities to your database. Finally it shows using the DatabaseContext to save and retrieve entities.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

Code First,C#,.NET,Architect,Intermediate,VS2012,.Net,Articles,Computer Tutorials,Entity Framework 4.1