entity-framework-4.3

Entity Framework (4.3) looking for singular name instead of plural (when entity name ends with “s”)

百般思念 提交于 2019-12-03 12:49:18
问题 Here's my situation: I have been working on an ASP.NET MVC 3 application for a while. It has a database (built out of a db project; I'm going db-first) for which I have an edmx model and then a set of POCOs. My entities have plural names in the database and POCOs have singular names. Everything maps nicely without a problem. Or used to until I added a new table (called TransactionStatuses). Now all of the old entities still work but the new one does not. When I try to eagerly load it together

Entity Framework Code First : How to map flat table to class with nested objects

给你一囗甜甜゛ 提交于 2019-12-03 12:23:59
I have the scenario where the data from a single table must be in 2 objects. [Table] -Field1 -Field2 -Field3 -Field4 And the class look like this: [Class1] -Field1 -Field2 -Class2 object here [Class2] -Field3 -Field4 I have set in the Class1 the attribute [NotMapped] over the property of the Class2 which contain the field 3 and 4. I also have added the configuration in the Database Context: public class ConfigurationClass1 : EntityTypeConfiguration<Class1> { public ConfigurationClass1 () { Property(o => o.Class2.Field3).HasColumnName("Field3"); Property(o => o.Class2.Field4).HasColumnName(

Entity Framework 4.3 with MVC on Edit doesn't save complex object

风格不统一 提交于 2019-12-03 09:03:24
I made a small project with Northwind database to illustrate the problematic. Here is the action of the controller : [HttpPost] public ActionResult Edit(Product productFromForm) { try { context.Products.Attach(productFromForm); var fromBD = context.Categories.Find(productFromForm.Category.CategoryID); productFromForm.Category = fromBD; context.Entry(productFromForm).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } } context is instanced in the constructor of the Controller as new DatabaseContext() . public class DatabaseContext

Running update-database from Team City

僤鯓⒐⒋嵵緔 提交于 2019-12-03 05:51:15
问题 I have created a new application using Entity Framework 4.3 database migrations. The migrations work great from the package manager console using the "update-database" command. Now I want to run the database migrations every time the application is built using Team City, it looks like I need to create a powershell script that will do this. Can anyone point me to some instructions on how to get the package manager commands to run from the command line, or powershell? All I can find is

Entity Framework 4.3 code first multiple many to many using the same tables

a 夏天 提交于 2019-12-03 04:46:20
问题 I have a model like public class User { [Key] public long UserId { get; set; } [Required] public String Nickname { get; set; } public virtual ICollection<Town> Residencies { get; set; } public virtual ICollection<Town> Mayorships { get; set; } } and public class Town { [Key] public long TownId { get; set; } [Required] public String Name { get; set; } public virtual ICollection<User> Residents { get; set; } public virtual ICollection<User> Mayors { get; set; } } I was hoping EF would create

Entity Framework (4.3) looking for singular name instead of plural (when entity name ends with “s”)

二次信任 提交于 2019-12-03 02:17:10
Here's my situation: I have been working on an ASP.NET MVC 3 application for a while. It has a database (built out of a db project; I'm going db-first) for which I have an edmx model and then a set of POCOs. My entities have plural names in the database and POCOs have singular names. Everything maps nicely without a problem. Or used to until I added a new table (called TransactionStatuses). Now all of the old entities still work but the new one does not. When I try to eagerly load it together with a related entity: var transactions = (from t in db.Transactions.Include(s => s.TransactionStatus)

Running update-database from Team City

99封情书 提交于 2019-12-02 19:11:00
I have created a new application using Entity Framework 4.3 database migrations. The migrations work great from the package manager console using the "update-database" command. Now I want to run the database migrations every time the application is built using Team City, it looks like I need to create a powershell script that will do this. Can anyone point me to some instructions on how to get the package manager commands to run from the command line, or powershell? All I can find is instructions on how to do this via the package manager console, which I don't know how to run from a Team City

Entity Framework 4.3 code first multiple many to many using the same tables

末鹿安然 提交于 2019-12-02 19:06:09
I have a model like public class User { [Key] public long UserId { get; set; } [Required] public String Nickname { get; set; } public virtual ICollection<Town> Residencies { get; set; } public virtual ICollection<Town> Mayorships { get; set; } } and public class Town { [Key] public long TownId { get; set; } [Required] public String Name { get; set; } public virtual ICollection<User> Residents { get; set; } public virtual ICollection<User> Mayors { get; set; } } I was hoping EF would create two many to many relationships using automatically created TownResidents and TownMayors table. I can't

Cannot Deploy MVC 3 Project with Entity Framework 4.3.1 and Oracle ODAC

非 Y 不嫁゛ 提交于 2019-12-02 09:04:47
问题 I'm currently trying to deploy a MVC 3 application I've been working on to our test web server, and am running into a major problem with loading everything correctly. To try and give as much info about this as possible, I'm doing a bin deploy (I've sent all references to copy locally), and am doing a basic Publish on the web project via file system to the application directory on the server. The components I'm using are: Entity Framework 4.3.1 Oracle ODAC 11.2.0 (version 4.112.3.0) This

Cannot Deploy MVC 3 Project with Entity Framework 4.3.1 and Oracle ODAC

喜夏-厌秋 提交于 2019-12-02 07:41:57
I'm currently trying to deploy a MVC 3 application I've been working on to our test web server, and am running into a major problem with loading everything correctly. To try and give as much info about this as possible, I'm doing a bin deploy (I've sent all references to copy locally), and am doing a basic Publish on the web project via file system to the application directory on the server. The components I'm using are: Entity Framework 4.3.1 Oracle ODAC 11.2.0 (version 4.112.3.0) This application has 2 Entity Framework objects, one going to a SQL Server database and the other going to an