Linked Questions

62 votes
3 answers
58k views

How to ignore a property when using Entity Framework Code First [duplicate]

Entity Framework Code First will auto-create a table in the database base based on the Model. Is there an attribute that will avoid this?
  • 4,917
2 votes
1 answer
5k views

Adding a virtual column to Table in Entity Framework? [duplicate]

I have the below dbcontext.cs and the corresponding table.cs which define the DAL in my MVC using entity framework. The List table in my database does not have a column C but I would like the entity ...
  • 349
33 votes
4 answers
47k views

Exclude a field/property from the database with Entity Framework 4 & Code-First

I will like to know that is there a way to exclude some fields from the database? For eg: public class Employee { public int Id { get; set; } public string Name { get; set; } public ...
  • 14.4k
51 votes
5 answers
18k views

How not persist property EF4 code first?

How do I make non persisted properties using codefirst EF4? MS says there is a StoreIgnore Attribute, but I cannot find it. http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-...
42 votes
2 answers
29k views

Have model contain field without adding it to the database? [closed]

In my Asp.NET MVC4 application I want to add a field to my model without adding it to the database. Sort of a field that only lives in c# instances of the model but not in the database itself. Is ...
  • 475
7 votes
9 answers
3k views

Building a dynamic JSON response in MVC 5 - How to tack on properties to a result set?

I am returning an array of objects to a page that renders a slideshow based on a photo album. I fetch my pictures from the database. Before I return this array as a result, I would like to tack on a ...
17 votes
2 answers
31k views

Exclude certain column from Entity Framework select statment [duplicate]

I have an image column in the product table in a SQL Server database. The image column is used to save the images as bytes. I know it is better to make a separate table for images, but I did not do ...
  • 539
5 votes
2 answers
4k views

Entity Framework Ignore property by conventions

I have a code-first model where all entities are derived from a Entity base class. I have a property IsDeleted in base class which I want to ignore in all entities (I cannot remove/comment IsDeleted ...
1 vote
1 answer
8k views

Using [NotMapped] to pass additional info to the view, when following Database first approach

I am working on an asp.net mvc-5 web application, and i am using entity framework 5.0. I have mapped my SQL server database tables which created an .edmx file. now i want to extend the model classes ...
4 votes
1 answer
1k views

Custom properties in partial class (Invalid column name)

I created my database by script, then used the scaffold command to create my classes in visual studio, I added a new partial class for an entity (User) in which I added some custom properties (this ...
2 votes
4 answers
4k views

Ignoring a JSON property in POST with oData

I'm trying to build an API with EntityFramework and OData v4. Issue : I need some extra data, extraProperty, that are not in my DB to create a new Item, but oData won't recognize this as an Item if I ...
  • 8,452
3 votes
0 answers
1k views

Code first ignore virtual properties

I have my db some relations between entities. For example house-rooms: public class House{ [Key] public int Id{get;set;} public string Address{get;set;} public virtual IList<Room&...
0 votes
1 answer
707 views

Create a Class for extend Model Classes in EF code first

I have a model class that has for example 3 properties and corresponding table in my data base. public partial class Person { public string prop1 {set; get;} public string prop2 {set; get;} ...
  • 12.5k
3 votes
0 answers
1k views

Entity Framework mapping exclude database table columns

I have a table in database named product and it has many columns: Id Name Price Size Color .... .. I want to create a class to represent this table only 3 columns. And I will map like this. public ...
  • 6,241
1 vote
2 answers
1k views

Define additional parameters to pass from View to Controller (using DropDownList)

I have used scaffolding templates to create the necessary parts in the Controller and the accompanying Views for my Model class Question pictured here: public class Question { [Key, ...

15 30 50 per page