entity-framework

app.config transformations not applying

故事扮演 提交于 2020-01-06 08:21:46
问题 I'm having an issue with app.config transformations using SlowCheeta not applying on publish. It always uses dbTable, not dbTableLive. app.config <connectionStrings> <add name="db2" connectionString="metadata=res://*/db2.csdl|res://*/db2.ssdl|res://*/db2.msl;provider=System.Data.SqlClient;provider connection string="data source=server;initial catalog=db2Table;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> <add name="db"

app.config transformations not applying

落花浮王杯 提交于 2020-01-06 08:21:03
问题 I'm having an issue with app.config transformations using SlowCheeta not applying on publish. It always uses dbTable, not dbTableLive. app.config <connectionStrings> <add name="db2" connectionString="metadata=res://*/db2.csdl|res://*/db2.ssdl|res://*/db2.msl;provider=System.Data.SqlClient;provider connection string="data source=server;initial catalog=db2Table;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> <add name="db"

Entity Framework 4.1 Code First - Keys/Navigation Properties

柔情痞子 提交于 2020-01-06 08:17:13
问题 Is this how you would setup a basic PK/FK relationship? Do you have to define both the key and the navigation property? Public Class Foo 'PK Public Property FooID As Integer 'Navigation Prop Public Overridable Property Bars As ICollection(Of Bar) End Class Public Class Bar 'PK Public Property BarID As Integer 'FK Public Property FooID As Integer 'Navigation Prop Public Overridable Property Foo As Foo End Class 回答1: This is basic configuration if you want default conventions to take care of

Alternative to SQL Server for a simple web app

十年热恋 提交于 2020-01-06 08:16:10
问题 I have a simple app written using SQL Server, Entity Framework, C# and WCF. When I wanted to share this app with my friends, I realised they didn't use SQL Server on their machine. I could go for SQL Server Express edition, as the usage of my app is personal and non-commercial. I found MySQL as a popular alternative to SQL Server. 1) Would I be required to update my entities when moving to MySQL? 2) Should I anticipate code changes in my BL layer due to change in entities layer? (I am

Recommended design pattern(s) to use [closed]

你。 提交于 2020-01-06 08:00:54
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Suppose I have very basic Task class as follows: public class Task { string Title { get; set; } } Now I want to add Planning

Splitting an Solution into multiple projects

偶尔善良 提交于 2020-01-06 07:56:45
问题 I created a Black Solution (Arhi) with a ASP.NET MVC 4 Internet project (Arhi.Core) and Class library project for data (Arhi.Data) where I'm storing my EDMX Model. I added a reference for Arhi.Data into Arhi.Core and I tried to add a Controller with a Model class from Arhi.Data (People entity) and I got this error. 'Unable to retrive metadata for 'Arhi.Core.People'. The specified named connection is either not found in the configuration, not inteneded to be used with the EntityClient provider

Query objects for one to many relationship in LINQ

自作多情 提交于 2020-01-06 07:54:35
问题 I have a problem which seems to be quite similar to Query objects for one to many relationship in LINQ I've been trying to solve my problem referring the above but somehow I've been failing for a long time. The scenario I have a model named Business which has a ICollection of Branches and also the business belongs to a particular SubCategory . The model Looks something like public class SubCategory { public string Id { get; set; } public string Name { get; set; } public string Description {

Query objects for one to many relationship in LINQ

Deadly 提交于 2020-01-06 07:54:11
问题 I have a problem which seems to be quite similar to Query objects for one to many relationship in LINQ I've been trying to solve my problem referring the above but somehow I've been failing for a long time. The scenario I have a model named Business which has a ICollection of Branches and also the business belongs to a particular SubCategory . The model Looks something like public class SubCategory { public string Id { get; set; } public string Name { get; set; } public string Description {

Which is the best way to use multiple models with sames properties and using a unique view?

筅森魡賤 提交于 2020-01-06 07:25:11
问题 For example, I have 3 models with an Id (int), a Name (string) and an active (bool). It's possible to use just one view for these models with the same properties ? A technique like a generic object ? Inheritance ? It's to avoid to write multiple views with the same HTML code. 回答1: You could create a ViewModel. For sample: public class CustomerViewModel { public int Id { get; set; } public string Name { get; set; } public bool Active { get; set; } } And create another ViewModel with a type

Updating a UserProfile and its Roles using Entity Framework

妖精的绣舞 提交于 2020-01-06 07:14:10
问题 I'm trying to find a way that would allow me to update a UserProfile entity along with a list of Roles that the user is assigned to. I've written the code below, but it doesn't work. public void UpdateUserProfile(UserProfile userProfile) { context.Entry(userProfile).State = EntityState.Added; var databaseRoleIds = context.Roles .Where(r => r.UserProfiles .Any(u => u.UserId == userProfile.UserId)) .Select(r => r.RoleId).ToList(); var clientRoleIds = userProfile.Roles.Select(r => r.RoleId)