entity-framework

Mapping a model into a dto and 'include' only the key of child element

有些话、适合烂在心里 提交于 2020-01-26 03:14:48
问题 I have the following Project model: public class Project { [Key] public int ProjectID { get; set; } public string Name { get; set; } public string Description { get; set; } public virtual ICollection<Screenshot> Screenshots { get; set; } } And I have the following Screenshot model: public class Screenshot { [Key] public int ScreenshotID { get; set; } public string ScreenshotName { get; set; } public byte[] ScreenshotContent { get; set; } public string ScreenshotContentType { get; set; } } As

WPF application doesn't work in other computers

百般思念 提交于 2020-01-26 00:42:10
问题 I have built a simple WPF application just to gain some experience with it. All it does is get information from a database when a user clicks on a button. The application works fine in my PC(using the publish option), but when I tried running it on my laptop and my friends' PC, the app crashed as fast as the button was pressed. I'm 99% sure it has something to do with Entity Framework, which I use to contact the database (all the the function that gets fired on the button click does is

Hard Coding the Connection String in Entity Framework

跟風遠走 提交于 2020-01-25 21:56:23
问题 I know that a lot of people think it is a bad idea to hard code connection info but I have a specific situation where I need to do it. Please don't downtick me because you think this is a bad idea - again, very specific circumstance. Using the code below, I get the following error on the LINQ statement: The underlying provider failed on Open. I have tested the connection string independently and I have no trouble connecting with it. public partial class Form1 : Form { public Form1() {

Hard Coding the Connection String in Entity Framework

空扰寡人 提交于 2020-01-25 21:56:10
问题 I know that a lot of people think it is a bad idea to hard code connection info but I have a specific situation where I need to do it. Please don't downtick me because you think this is a bad idea - again, very specific circumstance. Using the code below, I get the following error on the LINQ statement: The underlying provider failed on Open. I have tested the connection string independently and I have no trouble connecting with it. public partial class Form1 : Form { public Form1() {

Dependency injection not working in web api call

笑着哭i 提交于 2020-01-25 21:42:12
问题 Hi I am trying to build angular 2 web application using WebAPI, Entityframework that is loosely coupled using dependency injection. I am using unity for dependency injection. I have created multiple projects in one solution to address the separation concerns. I have configured the dependency in unity.config however when i execute the webapi application and type the following url http://localhost:8702/api/allcustomers , I get message saying the customer controller doesn't have parameter-less

How to display nested list and maintain MVC pattern?

雨燕双飞 提交于 2020-01-25 21:28:10
问题 Attempting to display nested list using MVC 6 and EF code first design. I'm using this Tutorial to get me started with MVC and am trying to take it to another level. Classes: public class Location { [Key] public int ID { get; set; } public string LocationName { get; set; } public ICollection<SubLocation> Sublocations { get; set; } } } public class SubLocation { public int ID { get; set; } public string SubLocationName { get; set; } } Running dnx ef database update sets up my EF database

multiple edmx in the same .net solution

我怕爱的太早我们不能终老 提交于 2020-01-25 21:21:07
问题 I have 2 project in my .net solution.each one has entity data model.how I can make an association between two entities one in the first project data model while the other in the second project data model in the same solution? what if each data model mapped to different database? 回答1: As far as I know you can't achieve this within a reasonable solution. 回答2: It is impossible to have a database relation between two fields in separate databases, however, you can do this of course with server

Entity Framework IsRowVersion() without concurrency check

不羁岁月 提交于 2020-01-25 21:03:35
问题 We have a table that has a column called Version that is mapped as a SQL rowversion . This is done because we have an external system that maps to our data that relies on this column changing every time the table is updated. Originally we wanted this to be handled by SQL, but now we are finding we have Optimistic Concurrency exceptions. While these exceptions are there to safeguard data getting overwritten, for our case we do not care about this. We simply want the timestamp to continue

UserStore with my own database

坚强是说给别人听的谎言 提交于 2020-01-25 11:31:59
问题 I'm trying to use my own SQL Server database to store the user permissions. I initialize the UserStore with my context like this (I tried with the default constructor also) UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>(new DbEpicerieEntities())); Then I created an empty database and generated the data model for entity. Then I changed the web config for my connection <connectionStrings> <add name="DefaultConnection" connectionString="metadata=res://*

UserStore with my own database

走远了吗. 提交于 2020-01-25 11:31:06
问题 I'm trying to use my own SQL Server database to store the user permissions. I initialize the UserStore with my context like this (I tried with the default constructor also) UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>(new DbEpicerieEntities())); Then I created an empty database and generated the data model for entity. Then I changed the web config for my connection <connectionStrings> <add name="DefaultConnection" connectionString="metadata=res://*