entity-framework-5

How can I resolve this error: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string

走远了吗. 提交于 2019-11-30 12:32:44
问题 How can I resolve these errors: Loading the include file 'EF.Utility.CS.ttinclude' returned a null or empty string. Value does not fall within the expected range. Tools Used: VS 2012, Entity Framework 5.0.0, T4MVCExtensions 3.5.0, .NET Framework 4.5 I've been using EF and T4 templates in a project within a large MVC solution without incident. Now, when I right-click on the edmx diagram, EF responds with the message: Value does not fall within the expected range. When I compile the EF project

Entity Framework 5 code-first not creating database

Deadly 提交于 2019-11-30 11:57:11
问题 I'm trying to create a new database using the code first concept of Entity Framework. However when running the code the database isn't created (using the DropCreateDatabaseIfModelChanges setting), though the code is running fine. I'm seeing the following exception when I try to get something from the database. My project is setup using a separate DataAccess layer with an generic service and repository construction. So all my entities, repository and also database context are in a separate

Entity Data Model Wizard Too Slow (SQL Database)

一个人想着一个人 提交于 2019-11-30 11:39:09
Using: visual studio 2012 Ultimate, ADO Entity Framework 6, Database: Sql express 2014 (installed on local PC), Database tables count: 174 table. I am trying to create database model using Entity Data Model Wizard but it takes about 8 hours to create the model(Dialog not responding). I tried to reinstall visual studio & Entity Framework but the same problem. I need any ideas that can speed up database model creation. Updating to Cumulative update package 5 for SQL Server 2014 fixes this issue, see https://connect.microsoft.com/VisualStudio/feedback/details/829555/visual-studio-freezes-during

Entity Framework Code First 5 Cascade Delete on many to many tables error

牧云@^-^@ 提交于 2019-11-30 09:38:09
I've this model public class State { public State() { this.Promotions = new List<Promotion>(); this.Branches = new List<Branch>(); this.Stores = new List<Store>(); } public int Id { get; set; } public string Description { get; set; } public virtual ICollection<Promotion> Promotions { get; set; } public virtual ICollection<Store> Stores { get; set; } public virtual ICollection<Branch> Branches { get; set; } } public class Store { public Store() { this.Promotions = new List<Promotion>(); this.Branches = new List<Branch>(); } public int Id { get; set; } public string Name { get; set; } public

EntityFramework 5 filter an included navigation property

て烟熏妆下的殇ゞ 提交于 2019-11-30 08:43:39
I would like to find a way using Linq to filter a navigation property to a subset of related entities. I know all answers around this subject suggest doing an anonymous selector such as: query.Where(x => x.Users.Any(y => y.ID == actingUser.ID)) .Select(x => new { Event = x, Discussions = x.Discussions.Where(actingUser.GenerateSecurityFilterFor<Domain.Discussion>()) }) .OrderBy(x => x.Discussions.Count()) .ThenBy(x => x.Event.Name); However, this is significantly less than ideal due to the general nature of our query generation and also yields significantly horrific sql queries if you throw up

Fluent API - one to many

放肆的年华 提交于 2019-11-30 08:40:33
I cannot seem to find a one-to-many relationship syntax in the fluent API. As an example I have two tables as below User Id Name UserHistory Id UserId Date In the classes I have the following public class User { public int Id { get; set; } public virtual ICollection<UserHistory> Histories { get; set; } } public class UserHistory { public int Id { get; set; } public int UserId { get; set; } public DateTime Date { get; set; } } I have tried the following but I am not sure if its actually correct. modelBuilder.Entity<User>() .HasRequired(w => w.Histories) .WithMany(); modelBuilder.Entity<User>()

EF5 Code First Migrations: “Column names in each table must be unique” error after using RenameColumn

人走茶凉 提交于 2019-11-30 08:39:10
We're using Entity Framework 5.0 Code First and Automatic Migrations. I had a class like so: public class TraversalZones { public int Low { get; set; } public int High { get; set; } }​ Then we realized these properties weren't really the right names, so we changed them: public class TraversalZones { public int Left { get; set; } public int Top { get; set; } }​ The rename refactored properly throughout the project, but I know Automatic Migrations aren't smart enough to pick up these explicit renames in the IDE, so I first checked to verify the only pending migration was this column rename:

Unable to run EF5 migration with existing database

牧云@^-^@ 提交于 2019-11-30 08:32:00
问题 First, I've read these questions/answers: EF-migration message How can I stop Add-Migration checking my database has no pending migrations when using Code-Based migrations? Make EF4.3 Code First Migrations ignore pending migrations These all seem to be for EF versions prior to EF5, and my situation doesn't seem to fit these answers. So, let me describe my situation. My application was originally created using EF4, model first. I designed my database with the GUI designer, and used it to

Changing column default values in EF5 Code First

梦想与她 提交于 2019-11-30 08:24:18
问题 I'm trying to use CF to build a model for an existing database. I have a column in which I forgot to set a sane default value. And rather than compromise the purity of the initial migration by changing it, I just figured I'd create another migration (that's what migrations are for, right? :) public override void Up() { AlterColumn("Config", "DefaultTaxPerDollar", c => c.Decimal(nullable: false, precision: 19, scale: 5, defaultValue: 0.087m)); } public override void Down() { AlterColumn(

No context type was found in the assembly

纵饮孤独 提交于 2019-11-30 07:53:54
I'm using .NET 4.0, MVC3, and EF5 with code first. My solution is split up into three projects, with the dependencies as indicated: Project.Web -> Project.BLL -> Project.DAL The Project.DAL layer contains my entity framework data context class and all my entities, but my startup project is Project.Web, so it contains my Web.config, connection strings, and the actual SQL compact database. I'm trying to enable migrations so I can add a new table to my EF model without wiping the existing data. However, when I run "Enable-Migrations", I get No context type was found in the assembly 'Project.Web'.