entity-framework-6

Unable To populate view or view model Updaed

微笑、不失礼 提交于 2019-12-02 12:34:50
Hi I am following up on this question here and working through a proof of concept for a SPA using our Company database data from a series of examples / articles Using Web API 2 with Entity Framework 6 Unfortunately, when I run the project I get this return This feels like a failure to retrieve the data from the SQL Database (SQL Server 2008R2). However I am getting no error message, which I though I would, I know the data view is there as I have checked in SQL Management studio and in Server Explorer of Visual Studio 2017. I am guessing though it could also be an error mapping my Data transfer

Why mapping is not working using Entity Framework in visual studio 2015 professional

天大地大妈咪最大 提交于 2019-12-02 12:18:22
问题 I have created a context of Entity Framework like below: using System; using System.Data.Entity; using System.Data.Entity.ModelConfiguration.Conventions; using System.Collections.Generic; using System.Linq; using System.Web; namespace UniversityApp.Models { public class ProfDb : DbContext { public DbSet<Professor> Professors { get; set; } public DbSet<Student> Students { get; set; } } } I am using VS 2015 Professional. Then I go to View=>Server Explorer=> Add Connection=> Microsoft Sql Server

project.Models.tableName:The field pvid must be a string or array type with a maximum length of '20'

瘦欲@ 提交于 2019-12-02 11:00:58
I encounter exception error below when i try to add a new entry in the database with : db.patient_visit.Add(pv); db.SaveChanges(); An exception of type 'System.InvalidOperationException' occurred in project.dll but was not handled in user code Additional information: project.Models.tableName:The field pvid must be a string or array type with a maximum length of '20'. Before this, my model is automatically and originally set like below because i did Code-First migration with existing database. [Key] [StringLength(20)] public string pvid { get; set; } Logically, it looks like it is already in

Adding new entries over entity navigation property collection

半城伤御伤魂 提交于 2019-12-02 10:27:37
I need to create a generic way to add missing languages entries to all entities in which implements an specific interface. I found out how to get my collection property, but I still don't know how to add new values on it before proceed to save. Following a piece of my public override int SaveChanges() handling. foreach (var translationEntity in ChangeTracker.Entries(<ITranslation>)) { if (translationEntity.State == EntityState.Added) { var translationEntries = translationEntity.Entity.GetType() .GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(x => x.CanWrite && x.GetGetMethod

Seeding method is inserting additional Entities with NULL values

时光怂恿深爱的人放手 提交于 2019-12-02 10:19:32
I am having this strange behavior all of a sudden (i have compared my files in version control (tfs) to be sure i did not change anything and i didn't found anything different). I am seeding my database with some metadata and i see that it has a very strange behavior i never saw before. I am inserting a Entity "Product" and it inserts this entity 2 times , first insert is correct and has everything it should have, the other one has NULL properties (string values) but some (like datetimes) have values. I have totally no clue why this is happening, it is occurring when i call the base.Seed(ctx);

Error when generating database from model in Visual Studio 2013

孤者浪人 提交于 2019-12-02 10:03:27
I have installed VS2013 but still have VS2012. In VS2013 I cannot generate a database from a model in Entity Framework. I get the following error message: The files in the error message do exist! Does anyone have any idea how I can fix this? Your tip about checking the drive made me see what I should have seen before. The environment variable VS120COMNTOOLS had the wrong drive letter. Can't remember, but I initially installed VS2013 on another drive and then changed it back to C. Anyway setting it correctly fixed the problem. /Peter Pawel I believe VS is not updating the VS120COMNTOOLS

Materializing an ICollection structure containing subclasses

梦想的初衷 提交于 2019-12-02 09:59:21
I'm reviewing some code that was written in the EF 4 days because it stands out during performance benchmarking. The purpose of the code is to materialize an ICollection<MyBaseClass> using Entity Framework (we're now on EF 6.1). The code exists because references present in specific subclasses aren't materialized when retrieving public Parent { public virtual ICollection<MyBaseClass>() Base { get; set; } } from the database, when the actual types stored are subclasses of MyBaseClass. Example subclass: public SubA : MyBaseClass { public virtual ICollection<Options> Ref1 { get; set; } }

Entity Data Model wizard disappears SQL Anywhere 17

大憨熊 提交于 2019-12-02 09:54:29
问题 I am trying to make a new model using Entity Framework 6 and SQL Anywhere 17. I followed exactly these steps. http://dcx.sap.com/index.html#sqla170/en/html/37fb9e8558e94547b66156b9298be16f.html But when I go through Entity Data Model wizard, it disappears after the following screen. 回答1: I got same Issue and able to resolve by following these step. Open server explorer tab- Delete all existing data connections- Rebuild your project- After this Entity Data Model wizard will not disappears. 来源:

asp.net mvc 5 entity framework 6 identity working with trust level = medium?

牧云@^-^@ 提交于 2019-12-02 09:41:45
Creating the simplest project (In visual studio 2013 -> asp.net web application -> MVC authentication with individual accounts), it works perfectly on localhost. However, when sending to the server (medium trust level), the project does not work when I try to enter login. See the error image: http://s18.postimg.org/fm2qw8gzt/print.png I tried to include on assembly.cs [assembly: AllowPartiallyTrustedCallers]. It did not work. I have created a strong name key. It did not work. The server does not support level = full trust. Do not believe there need to be full, because few asp.net mvc 5 sites

Entity Framework InverseProperty annotation usage

依然范特西╮ 提交于 2019-12-02 09:19:04
if I have the following models, am I using the InverseProperty correctly? class Person { public int PersonID {get;set;} [InverseProperty("Person")] public List<Hobbies> Sports {get;set;} [InverseProperty("Person")] public List<Hobbies> Art {get;set;} [InverseProperty("Person")] public List<Hobbies> Reading {get;set;} } abstract class Hobbies { public int HobbiesID {get;set;} public string HobbyName {get;set;} public int HobbyRating {get;set;} public int PersonID {get;set;} public Person Person {get;set;} } class Sports : Hobbies {} class Art : Hobbies {} class Reading : Hobbies {} this works