entity framework model to database with indexed properties - c#

I'm using EF 5.0 and diagram modeler (*.edmx) to create schema and generating database from model, and I was wondering if there is any way to create index on some property (only) via this modeler.
Many thanks for answer or advice.
//edit
I'm working on it, if I success, I'll share a little "how to".

Here is an article about Model-First in the Entity Framework 4
Read the sections about Generating the DDL and Influencing the DDL Generation
Update
Take a look at this example too: Entity Framework Part 5 Model First : Create a database with the Complex Types.

Related

C# interview questions approaches in entity Framework?

In my recent interview, my interviewer we asked about approaches in entity Framework I told them code first and table first. Is there any approaches pending.
We can use three type of entity framework approach as per project requirement.
Database First:
An existing database can be used
Code can be auto-generated.
Extensible using partial classes/ T4 templates
The developer can update the database manually
There is a very good designer, which sync with the underlining database
http://www.entityframeworktutorial.net/database-first-with-entity-framework.aspx
Code First:
There is full control of the model from the Code; no EDMX/designer
No manual intervention to DB is required
The database is used for data only
http://www.entityframeworktutorial.net/code-first/what-is-code-first.aspx
Model First:
Good support with EDMX designer
We can visually create the database model
EF generates the Code and database script
Extensible through partial classes

Entity framework adding existing classes to Entity Framework Model Diagram

Hi I'm new to Entity Framework so excuse me if this question seem simple, but I have tried to find an example or question where this is described.
I have built a webApi interface with classes in what I call an eventmodell. The Interface and model is working well to receive stuff. But now I would like to build the CRUD functions to the database with Entity Framework.
I have added an empty code first model, but then I don't now how to generate csdl, msl and ssl files needed to create the database.
I have added Empty EF designer model but have found no way of adding an existing class to the designer.
I have installed EF Power Tools but that didn't help.
You seem to have a misunderstanding on how Code First works as compared to Database First.
There is no designer needed in a Code First approach. You add classes to your model, setup a DbContext and use Migrations to setup, and then at later stages, alter the database structure.
Checkout this tutorial: Getting Started with Entity Framework 6 Code First using MVC 5

Manual object mapping in ado.net entity

I writing data access layer using ado.net entity. But I want do it by manual (not generate code by tool).
I need help how to do it, how many step and example.
You may want to have a look at Entity Framework Code First. See EF 4.1 Code First Walkthrough

Entity Framework 4.1 dynamically retrieve summary for scalar properties from database table column description

I'm using Entity-Framework 4.1 database-first approach. I have a legacy database which every table column has description. It's very helpful when you watch those description in database diagram.
At the same Entity Framework DataContext has a Summary property for each scalar value.
I'm wondering is there any way I could load those descriptions from the database and map them to the Summary of scalar properties ?
I would appreciate any directions
Take a look at How can I make the Entity data model designer use my database column descriptions?, Vote for the feature at https://connect.microsoft.com/VisualStudio/feedback/details/498313/retrieve-the-sql-descriptions-in-entity-framework [See update], Or if you are in a hurry, buy a third party tool at http://huagati.com/dbmltools/.
Update: Just found out that ADO.Net team has marked the feature as Won't fix in Their feedback center. But found a tool that does the work at http://eftsqldocgenerator.codeplex.com/. Haven't tested it though.

C# class to Sql table

There are a lot of Sql table -> C# class methodologies, but I'm looking for the reverse.
Hypothetical situation:
I have N classes populated by some web service I consume, manipulate, then preform an action on. Now the boss wants said web service data persisted in a database.
I already have the classes defined, how can I quickly and easily (aka, lazily) generate a sql table off of each class?
Entity Framework and nHibernate both allow you to use them in "code-first" mode, which involves writing classes then generating databases.
There is a walk-through of this on ScottGu's blog here: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
you can use MS Entity Framework Code First approach:
Code First allows you to define your model using C# or VB.Net classes,
optionally additional configuration can be performed using attributes
on your classes and properties or by using a Fluent API. Your model
can be used to generate a database schema or to map to an existing
database.
read more about it here: EF 4.1 Code First Walkthrough
Entity framework 4 has a code first development feature, I haven't used it so can't really recommend it
ScottGu blog

Categories

Resources