Questions tagged [ef-model-first]

231 questions
0
votes
0 answers

EF: Model First issues

as you've seen in my recent Posts, I'm trying to make use of the Entity Framework. So our DB-guy created me a Table called SalesOrder. So, I created a Project called DataLayer.SQL and used the Wizzard for the Model first Creation of my Table. BUT:…
Matthias Müller
  • 3,336
  • 3
  • 33
  • 65
0
votes
1 answer

How to change foreign key in Entity Framework

Using Entity Framework I can't get the foreign key to change when I do db.SaveChanges(). In the example below 'Salutation' is a foreign key in the 'person' model. E.g If it is currently {"Id":2,"Name":"Mrs"}, if I pass in {"Id":3,"Name":"Mr"},…
Holland Risley
  • 6,969
  • 9
  • 25
  • 34
0
votes
1 answer

Custom ICollection List Setter in a Entity for code first

I'm using EF6, and I'm wanting to move the initialisation of my collections to the Entity itself, so the code can be written once, the tutorials don't do this, just wondering if it's ok? I don't know enough about the Entity Frameworks under the hood…
David van Dugteren
  • 3,879
  • 9
  • 33
  • 48
0
votes
2 answers

Defining key for derived entities from base Entity

I want to derive TimeCondition entity from Condition entity, so I created this model (with abstract Condition): but on validation, it says: Error 3 Error 159: EntityType 'SHomeModel.Store.TimeCondition' has no key defined. Define the key for…
Majid
  • 13,853
  • 15
  • 77
  • 113
0
votes
1 answer

EF ComplexType column name (ModelFirst)

I'm working on a EF 6 project (ModelFirst). I use a complex type named "UserInfo" in all my tables. But, when I create my database from my model, columns are prefixed by the name of the complex type ( ex: UserInfo_CreationDate) Is there a way to…
Chrstpsln
  • 765
  • 16
  • 31
0
votes
1 answer

Model-first Entity Framework - how to have multiple schemas

I googled/searched for an answer here in SO, but didn't find anything, specially specific for model-first approach. I am just starting with creation of a new model for my new database and want to organize the entities for tables that logically…
tiwarib
  • 441
  • 6
  • 17
0
votes
0 answers

Entity Framework Model First Database with inheritance strange bug

I am learning EF and Model First approach. I had created a test app and all works, but with strange bug. I have a table, which has inheritance. Here it is my EDM scheme: http://gyazo.com/fbec21b5fbfc47dd76ff3eaa38f86d36.png Also i had a three rows…
BJladu4
  • 263
  • 4
  • 15
0
votes
2 answers

Create multiple Entity Data Model with individual connection string settings

I have a solution with 3 projects. A console project and two class library projects. Each class project has an EDM item added with one Entity. So I use Model First approach. Each class project has its own app.config with:
Pascal
  • 12,265
  • 25
  • 103
  • 195
0
votes
1 answer

What must i do with script, generated by EDM model?

I am writing a test app, using Entity Framework with model-first approach. I had created an EDM model with tables, than created a SQL Server CE database, created connection to db and than Master created a file *.edmx.sqlce with big sql script. What…
BJladu4
  • 263
  • 4
  • 15
0
votes
1 answer

Non nullable navigation property is null in Entity Framework

We have encountered Entity Framework returning NULL values for non-nullable relationships. We work model first. The problem occurs when an entity's relationship has been changed in a different context(or in our real use case: a different…
Olaf
  • 879
  • 6
  • 19
0
votes
1 answer

One Model or Two? - Database First EF 6.0 to SQL Server (2005/2008) needs offline support to SQL Server CE 4.0

I'm re-writing an old VB6 application which used SQL Server 2005 and Access MDB in VS 2013 C# with EF 6.0 to SQL Server 2008 R2 and SQL Server CE 4.0. The app has to function offline in the event of network errors, of which there are many. The…
0
votes
1 answer

Forcing EF 6 to create tables with model first

Currently I have a nice model, and I can generate a database based on that, but from what I can tell, the tables are never created (leading to all sorts of fun runtime errors). My understanding is that there are three options for code first that…
soandos
  • 4,978
  • 13
  • 62
  • 96
0
votes
3 answers

How to set up authentication with roles in an ASP.NET MVC5 application?

I am in the progress of adding a login system to an ASP.NET MVC5 application (previously MVC4 but converted to MVC5) and am having trouble with the conflicting and confusing information on adding accounts and roles to a website. I do not have an…
0
votes
1 answer

MVC Code- or Model First

Most of the tutorials for MVC with Entity Framework are centered around Code-First, where you write classes for generating the model. This gives the advantage of control and Migrations, but I think it lack overview. I would therefore prefer to…
0
votes
1 answer

Entity Framework Model First 1:0..1 Relationship

I created the following model in the Entity Framework 5 Model Designer in Visual Studio 2012: Then I generated the database from the model, which resulted in the following tables in my database: Please help me understand why Entity Framework is…