entity-framework-6

The provider did not return a ProviderManifest instance

故事扮演 提交于 2019-12-11 12:33:21
问题 when I want to configure my Datasource (EntityDataSource1) and assign the connectionString that is generated automatically by entity data model to it. I get the error: "The metadata specified in the connection string could not be loaded. Consider rebuilding the web project to build assemblies that may contain metadata. The following error(s) occurred: The provider did not return a ProviderManifest instance". I read so many suggestions like http://blogs.teamb.com/craigstuntz/2010/08/13/38628/

Reusing a column for a required property with Entity Framework 6.0, Fluent API, and DataAnnotations

≡放荡痞女 提交于 2019-12-11 12:19:08
问题 I have a base class public class BaseClass { public int Id {get; set;} } and two derived classes public class Foobar: BaseClass { [Required] public int Whatever {get; set;} } public class Snafu: BaseClass { [Required] public int Whatever {get; set;} } I'm using Table Per Hierarchy inheritance and trying to cut down on my duplicate columns, so with Fluent API I've mapped them like so: modelBuilder.Entity<Foobar>().Property(fb => fb.Whatever).HasColumnName("Whatever"); modelBuilder.Entity<Snafu

Unable to cast object of type 'System.Data.Entity.Infrastructure.DbQuery' to type 'PagedList.IPagedList'

大憨熊 提交于 2019-12-11 12:15:42
问题 I am trying to use pagination for a ASP.NET MVC 5 application. I have used X.PagedList I have implemented it correctly in a simple object, but I have problem when implementing it with a more complex object. For example like when I have relationship like Posts and Comments in a forum. My models have the following structure public class PublicReport { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int PublicReportID { get; set; } public string Title { get; set; } ... public

EF6 Does not generate foreign key association from database

こ雲淡風輕ζ 提交于 2019-12-11 11:47:48
问题 PROBLEM: I am trying to create a EF6 model using the database first approach. Simply speaking, I have 2 tables tblUser and tblMilkMan which have a foreign key relationship on the UserID column. But when I create a new EDMX diagram and add the 2 tables: I dont see the relationship No navigation properties are created Please tell me what Im doing wrong! DB Schema: Table Scripts: CREATE TABLE [dbo].[tblMilkMan] ( [RecordID] [INT] NOT NULL IDENTITY(1, 1) , [UserID] [INT] NOT NULL , [IsMyTurn]

How do i create the following LINQ expression dynamically?

折月煮酒 提交于 2019-12-11 11:17:18
问题 I need the following C# code to be translated to a valid Entity Framework 6 expression: (f => f.GetType().GetProperty(stringParamter).GetValue(f).ToString() == anotherStringParameter) This guy did it for the "Order By" part, but i cant seem to figure it out for the "where" part... Generically speaking what i am trying to achieve here is a form of dynamic query where the user will "pick" properties to filter in a "dropbox", supply the filter-value and hit query... usually people do like f => f

Why is there an implementation difference between the UserStore and the RoleStore?

柔情痞子 提交于 2019-12-11 11:13:51
问题 This has no problems: public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { public ApplicationUserStore(MyAppDb context) : base(context) { } } While this: public class ApplicationRoleStore : RoleStore<ApplicationRole, string, ApplicationUserRole> { public ApplicationRoleStore(MyAppDb context) : base(context) { } } ...produces the following compile time error: The type 'MyApp.Models

Easy way to fill object

一曲冷凌霜 提交于 2019-12-11 10:55:18
问题 I have the following class: public class SectionViewModel { private static EFModels.VTSEntities _db = new EFModels.VTSEntities(); public int ID { get; set; } public string SectionName { get; set; } public bool Active { get; set; } public string SiteName { get; set; } } I want to select one element from _db.Sections and fill object of this class. I can do it like it: public SectionViewModel(int ID) { var s = (from i in _db.Sections where i.ID == ID select new SectionViewModel() { ID = i.ID,

Async calling with multiple contexts

馋奶兔 提交于 2019-12-11 10:47:23
问题 So I have code pseudo-similar to (dependency injected): public DbContextA DBA { get; set; } // SQL Server 1 public DbContextB DBB { get; set; } // SQL Server 2 I'm just now sure how I can most effectively do the following? public Task<ActionResult> MyAction() { var trucks = await DBA.GetTrucksAsync(); var cars = DBA.GetCarsAsync(); var cats = await DBB.GetCatsAsync(); var dogs = DBB.GetDogsAsync(); await TaskEx.WhenAll(cars, dogs); } Unless I'm mistaken this isn't optimal. I think it would be

How can I turn off Entity Framework 6.1 logging?

坚强是说给别人听的谎言 提交于 2019-12-11 10:43:03
问题 The documentation states that I can turn on logging like this: using (var context = new BlogContext()) { context.Database.Log = Console.Write; // like this context.Database.Log = logInfo => Debug.WriteLine(logInfo); // or like this // Your code here... // How can I turn off logging here ? } I don't see any information on how to turn it off. Can someone tell me how I can do this? 回答1: Just call context.Database.Log = null; then you have turned of logging 来源: https://stackoverflow.com/questions

Code First Migration Entity Framework 6 Empty Up/Down

戏子无情 提交于 2019-12-11 10:40:08
问题 The problem I'm having is that when I "Add-Migration", it seems that no comparison against the target database is done and the Up/Down methods are empty. This starts from me targeting different environments. The migration changes work fine when I update-database and it targets one particular database, my dev database. When I change the connection string to target another database, another dev box on another server, and try to add-migration for that particular environment, the Up/Down methods