entity-framework-5

Entity Framework 5 Cannot use Ignore method on the property

我与影子孤独终老i 提交于 2019-12-11 08:55:08
问题 I have almost exhausted all of the workarounds for this bug: http://entityframework.codeplex.com/workitem/481 Please can someone point me in the right direction. I have done the following: Step 1: Remove the NotMapped attribute from the properties in all entities and base classes. There are no NotMapped attributes left in my solution at all. Step 2: Use the ignore method in the OnModelCreating method for all properties on all entities (Seriously this took me a couple days with the sheer

Enum type not being mapped to DB table

别来无恙 提交于 2019-12-11 08:14:27
问题 I'm using EF 5.0 Code First, in a .NET 4 library. Trying to set a class member to be of an Enum type, but it doesn't get persisted to the database, and no runtime exception occurs when EF is creating the database based on the code. Of course, when I try to query against that Enum: var departments = db.Departments .Where(dep => dep.Name == DepartmentNames.English); I get an exception saying: The specified type member 'Name' is not supported in LINQ to Entities. Only initializers, entity

MetadataType buddy class for EF generated POCO - attributes are ignored by XmlSerializer

随声附和 提交于 2019-12-11 07:41:24
问题 I am using EF5 database first. In order to serialize a generated POCO class, I need to use the XMLIgnore attribute as follows public partial class Demographics { public string KeyTract { get; set; } public string CollectionYear { get; set; } public string MSAFIPS { get; set; } ... ... ... [XmlIgnore()] public virtual ICollection<LoanApp> LoanApps { get; set; } } In order to keep from adding this each time I have EF re-create the model from the database, I added a "buddy class" [MetadataType

EntityFramework with WCF - how to return EF entities

北城以北 提交于 2019-12-11 06:33:51
问题 I have a WCF service which works, but it uses Standard ADO.net to call some stored procedures. This is a bit messy and annoying to maintain because any stored procs i call, i have to map to DataContracts i have to create manually and then return as JSON. I would like to convert the WCF service to return EntityFramework entities (so i dont have to keep mapping and creating datacontracts manually). I have something like this in my method, eg: public List<GetStuff_Result> GetStuff(string param1)

Entity Framework Database First with proper use of Data Anotations

时光怂恿深爱的人放手 提交于 2019-12-11 06:19:45
问题 I have one project with EF and Code First approach and there using of Data Annotations was straight forward. Now I'm working with Database First and I see that using Data Annotations is more specific so I want to know the right steps to implement it. The structure of my project that provides Data Access is this: In ModelExtensions are all my files that I've created to add the Data Annotations to the DbContextModel.tt entities. Here is the structure of one of my files in ModelExtensions :

how to delete assigned courses only not all courses for employee

非 Y 不嫁゛ 提交于 2019-12-11 05:53:15
问题 Problem In edit view when i click remove course then click save it remove all course not only i selected for remove Details if i have courses a,b,c for employee name michel then remove course a and click save it delete all courses b,c also deleted I need actually delete assigned for remove only meaning remove a and remaining b,c. see image below it show what i need clearly model Cusomemp2 public class Cusomemp2 { public int Id { get; set; }//employee public string Name { get; set; }//employee

How to join Aspnet_User to my custom user

送分小仙女□ 提交于 2019-12-11 05:52:44
问题 I have a User model object and I wan't to when I get this object to get aspnet_User object with it for additional data ( usename etc.) public class User { public Guid UserId_fk { get; set; } public int UserId { get; set; } public string FirstName { get; set; } public virtual AspnetUsers AspnetUsers { get; set; } } public class AspnetUsers { public Guid ApplicationId { get; set; } public Guid UserId { get; set; } public string UserName { get; set; } public string LoweredUserName { get; set; }

how to get data from multiple related tables and pass it to the view mvc

家住魔仙堡 提交于 2019-12-11 05:27:58
问题 i have three table in my data base category and Subcategory and product: category has many Subcategory Subcategory has many product so i'm trying to join this three table to get the data for each product and display it in a view like that: public ActionResult Index() { var memberId = WebSecurity.CurrentUserId; var productsCompany = db.Products .Join(db.SubCategorys, p => p.SubCategoryID, subcat => subcat.SubCategoryID, (p, subcat) => new { p = p, subcat = subcat }) .Join(db.Categorys, temp0 =

How do I Enable Migrations in the Package Manager Console?

前提是你 提交于 2019-12-11 04:30:03
问题 I'm trying to enable migrations in MVC4, Entity Framework 5.00, however when I input the command it throws the following error: Cannot determine a valid start-up project. Using project 'EFMigrations' instead. Your configuration file and working directory may not be set as expected. Use the -StartUpProjectName parameter to set one explicitly. Use the -Verbose switch for more information. Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file://\\s01\data

“If Any Contains Any” (DbExpressionBinding requires an input)

喜欢而已 提交于 2019-12-11 04:02:36
问题 I'm trying to build a simple search where I pass a list of keywords. But soon as I add the "any contains keywords" as a list instead of a string I get: "DbExpressionBinding requires an input expression with a collection ResultType." I have extended IQueryable<Inspector> with: public static IQueryable<Inspector> Search(this IQueryable<Inspector> qry, List<string> keywords) { return from i in qry where i.LastName.Any(x => keywords.Contains(i.LastName)) || i.FirstName.Any(x => keywords.Contains