Questions tagged [ef-model-first]

231 questions
1
vote
0 answers

EF Core 6 is generating duplicate foreign keys on base type and inherited types when scripting the dbcontext

I have an existing database using table per type inheritance. The BaseTypes table has a primary key with two columns (Id and ShopCode) and a named foreign key (FK_BaseType_Shops) to another table (Shops) using the ShopCode column. There are two…
1
vote
1 answer

EF Generate Database from Model Deletes Function Imports

Ok I've seen this question Entity Framework: Generate Database From Model removes Stored Procedures from Model Store but I don't think this is solved. I have some function which I need to run at SQL Server in selection for filtering. I wasn't able…
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
1
vote
0 answers

Computed column based on rows from another table

I have the following (simplified) table public class Door { public int Id { get; set; } public bool Locked { get; set; } } Now the problem with this table is that I don't know how long the door has been locked or not. I could add a new…
1
vote
2 answers

Image datatype in EF 4.1 model first

We have a project which used Entity Framwork 4.0. We draw the model and then generate an SQL Compact 3.5 DB. Since we needed a large BLOB store, we created a column with the Image data type (since Binary is limited to 8000 bytes). However, when…
1
vote
1 answer

Is it possible to generate a different column name for a property when generating SQL schema from the .edmx file?

I've "inherited" an EF 4.0 .edmx file. Currently a given property name and column name are identical in the generated C# and SQL schema. I've since upgraded to EF 4.1, and changed the code generation item to generate a DbContext instead of an…
Kit
  • 20,354
  • 4
  • 60
  • 103
1
vote
1 answer

Entity Framework Optimistic Concurrency exception with DateTime

I have inherited a legacy codebase for an existing system. Some new features are to be added and bugs are to be fixed, but the database cannot be changed. One of the bugs is that when trying to update records from a specific table, I get the…
1
vote
1 answer

DbContext fails to initialize Model-first database

Update: It turns out I had (hidden away in my POCO objects) a property with an abstract type. Removing this property solves the issue. I'm trying to have a model-first scenario with entity framework 4 ctp 5 generate my database (currently using a…
1
vote
1 answer

'Add Foreign Key Property to..' checkbox disabled for 0..1 to 1 relationships

On the model-first approach in the designer, if I create a relationship where the cardinality on one end of the relationship is '0..1' and '1' on the other, the designer disables the 'Add Foreign Key Property to..' checkbox. For example, say that I…
Tom Martin
  • 11
  • 1
1
vote
1 answer

How to create RowVersion column for optimistic concurrency using model first approach?

I am working on a legacy web app which implements model first(edmx file) approach using Entity Framework. I need to implement optimistic concurrency, so I have added this field as following: and inside the database has been created as binary(8)…
1
vote
1 answer

How to add a primary key to a View - Oracle

I have a View in an Oracle database. I want to use this view in my ASP.NET MVC project. I know that in order to add that view to EF, that view needs to have a primary key. I don't know how to add a primary key as a new column to that view. None of…
jason
  • 6,962
  • 36
  • 117
  • 198
1
vote
1 answer

(EF6 Model first) How can I get the value of a foreign key without accessing the navigation property so that I don't need to load the full entity?

How can I get the value of a foreign key without accessing the navigation property so that I don't need to load the full entity? public class A { public int Id {get;set;} // ... } public class B { public virtual A A {get;set;} //…
1
vote
0 answers

(Entity Framework) Can't Delete Table with Many-to-Many Relation Even with Lazy Loading Disabled

I did search extensively on this issue, but because of some unique constraints on the project, none of answers were applicable. ISSUE: I inherited a model-first mvc app that's refusing to delete tables that have many-to-many relations because of…
1
vote
0 answers

Need advice regarding handling updating many-to-many relationships in Entity Framework

WHAT I HAVE: Visual Basic 2015, Entity Framework (DBContext), WinForms MY PROBLEM: I'm writing a VB 2015 program using EF (Model-First, since I'm starting from scratch), and some of my entities have many-to-many relationships. I read that in order…
1
vote
2 answers

Model first DbContext creation in Entity Framework 6

In my web project I am trying to use Entity Framework 6 model first approach. Model is generated from existing database in separate project. For model generation connection string is saved in app.config of data access project. In main web project…
1
vote
1 answer

How do enable migrations to a Model First EF project? (edmx based)

I started a project using Model First project creating a empty EDMX file and created a whole new DB. this DB was populated with data on production server for weeks. Now I just add more columns to the table model. I would like to create a migration…