entity-framework-5

The entity type is not part of the model, EF 5

此生再无相见时 提交于 2019-12-01 05:24:34
I am trying to update my repository to EF5 but have encountered a few errors. I've taken a look around stackoverflow for similar errors discovered a few questions/answers but unfortunately the same answers didn't resolve my issue. This is my error: The entity type User is not part of the model for the current context. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. This is my DbContext class: public abstract class WebModelContext : DbContext {

Entity Framework Automatic Migrations Existing Database

久未见 提交于 2019-12-01 05:12:04
问题 I am building an ASP.Net MVC4 web application with Entity Framework 5. I had to use an existing sql server database but also wanted to use Code First, so I followed this tutorial http://msdn.microsoft.com/en-us/data/jj200620.aspx My application uses automatic migrations with Entity Framework. The version of sql server I was using throughout the development phase was 2008, however, at the last minute I've been told the database needs to work on sql server 2005. I got the database I was using

Execute SQL Alter commands for every session with Entity Framework 5 talking to Oracle 11g

六月ゝ 毕业季﹏ 提交于 2019-12-01 04:55:39
问题 I have a requirement to execute some SQL commands at the start of every database session. I am using Entity Framework 5 via DbContext talking to a Oracle 11g database. I would like to execute: ALTER SESSION SET NLS_COMP=ANSI; ALTER SESSION SET NLS_SORT=BINARY_CI; at the start of an session creation to get case insensitive searching. How best could I go about this? I've put the commands in the constructor of dbContext, but have only simple unit test and it does appear to work. But unsure if

Seed Database at Application Start - ASP MVC 3 and EF

徘徊边缘 提交于 2019-12-01 04:53:20
问题 For some reason I cannot get my application to seed the database with some test data when the application starts up. Order of execution: 1) Application_Start() in Global.asax - Database.SetInitializer<LocatorContext>(new DropCreateDatabaseAlways<LocatorContext>()); - new LocatorContext.DropCreateIfChangeInitializer() .InitializeDatabase(new LocatorContext()); 2) onModelCreating() in my DBContext class 3) Page is rendered and no data is inserted into the database Any thoughts as to why or how

Entity framework Invalid Column name, EF adds numer 1 to primary key

戏子无情 提交于 2019-12-01 04:23:08
I have these two entities: public partial class Suscriptores { public Suscriptores() { this.Publicacion = new HashSet<Publicacion>(); } [Key] public int IdSuscriptor { get; set; } public string LogoSuscriptor { get; set; } public string Identificacion { get; set; } public string Nombre { get; set; } public string Direccion { get; set; } public string Telefono { get; set; } public string Email { get; set; } public string Fax { get; set; } public string Home { get; set; } public virtual ICollection<Publicacion> Publicacion { get; set; } } public partial class Publicacion { public Publicacion() {

Windows Azure, Entity Framework. Keyword not supported: 'metadata'.

人走茶凉 提交于 2019-12-01 04:18:46
This has been asked a few times but I haven't been able to make any of the suggestions work for me. I have a website and SQL database that I've build locally and now deployed into Azure. The database is a linked resource to the website. I am able to browse the website and I'm even able to connect and run queries against the database using ADO.Net and a standard connection string. The problem is when I try to connect using Entity Framework I keep getting Keyword not supported: 'metadata'. I've removed the multiple active record sets and tried replacing " with ' but it hasn't work. I'm

EntityState.Deleted does not work, Remove(entity) does?

蹲街弑〆低调 提交于 2019-12-01 03:56:53
问题 I've been struggling with EF when trying to read records, then delete those records in the same transaction. I was initially using the EntityState.Deleted method, which would give an error: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be

Can Entity Framework handle many to many relationship without an intersection object?

放肆的年华 提交于 2019-12-01 03:39:40
Using database first model: Let's say we have the classic tables Student , Course and StudentCourse (the latter obviously having FKs to Student and Course ). If you import this model to EF, you will get an object generated for each of them. The Student and Course classes will each have a collection of StudentCourses , from which you need to jump another relationship to get to the Course or Student , respectively. I would like to have the code generated in such a way that the underlying intersection table is invisible, i.e. Student has a collection of Courses , and Course has a collection of

Where is my database and how do I view it?

走远了吗. 提交于 2019-12-01 03:03:11
I've just created a brand new application, added EntityFramework 5 via NuGet, created a very basic DbContext and saved some data to it. Where exactly is my data and how do I view it? The unmodified App.config it added is <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

Entity Framework 5 - Looking for Central Point to Execute Custom Code after Entity is Loaded from Database

有些话、适合烂在心里 提交于 2019-12-01 02:59:27
I am using Entity Framework 5 with Code First approach and using Fluent API for Entity configuration. My project has one particular Product Entity which gets half of its data from the database and the other half from a Data Contract retrieved via a WCF Client (its a 3rd party system used to manage product inventory). The Data Contract is a member of the Product Entity class (property or method I haven't decided yet). I prefer not to have any WCF Client logic contain within the Entities. I'd prefer to keep this logic in Repository code (DbContext, DbSet, etc.). So is there a technique to hook