entity-framework-6

Upgrade to EF 6.1.1 makes effect of [NotMapped] disappear

喜夏-厌秋 提交于 2019-12-23 07:57:16
问题 I have upgraded from EF 4.3.1 to 6.1.1 and now it seems like the annotation [NotMapped] is useless. Yes, i have change to correct assembly and everything looks fine on compilation. Everywhere where [NotMapped] is present the property is handled as a domain property and i get an error that EF can't find the matching column in database. Example: private bool _authenticated = true; [NotMapped] public bool Authenticated { get { return _authenticated; } set { _authenticated = value; } } Yes, it

How to cast DbSet<T> to List<T>

谁都会走 提交于 2019-12-23 07:45:56
问题 Given the following simplified Entity Framework 6 context, I am trying to populate a List with the entities but having problems with how to cast (I believe) via reflection. public class FooContext : DbContext { public virtual IDbSet<FooClass> Foo { get; set; } //... } public class FooClass { public int Id{ get; set; } public string Name {get; set; } //... } public main() { using (var context = new FooContext()) { var sets = typeof(FooContext).GetProperties().Where(pi => pi.PropertyType

Best way to fetch data from localized database

会有一股神秘感。 提交于 2019-12-23 05:19:50
问题 I created table structure to make statuses localized in database: Status {StatusId, Value} -- Value in this table is status value in default language StatusTranslation {StatusId, Language, TrasnlationValue} -- StatusId and Language are combined key But I am having trouble to make this work in entity framework. When default languege it is easy Status.ToList() but when I need translation I pass to the get method de-CH but I can't return translated Status. What is the best way to map this using

Entity Framework Code First Set Foreign Key Name

孤人 提交于 2019-12-23 05:03:35
问题 I have two tables: User ID Email Task Email TaskName The user can have multiple tasks. I need to specify that Email is the foreign key relationship between my task and email table. How can this be done? Here is my code: public MyDataContext() : base("Default") { } public DbSet<User> Users { get; set; } public DbSet<Task> Tasks { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<User>() .ToTable("User").HasRequired(m => m.Tasks) .WithMany()

How to send CustomerName and CustomerSurname from Controller to edit or create cshtml

╄→尐↘猪︶ㄣ 提交于 2019-12-23 04:54:16
问题 I want to send CustomerName and CustomerSurname from Controller to edit or create cshtml but I am getting error as: System.Data.Entity.DynamicProxies.CUSTOMERS_14601EA232CC1C78E8EEE3B8325EDF47D2BEC1CCBF414A98771B931D28B27715' does not contain a property with the name 'CustomerName CustomerSurname'. The Controler // GET: PAYMENT/Create public ActionResult Create() { ViewBag.PaymentCustomer = new SelectList(db.CUSTOMERS, "CUSTID", "CustomerName" + " " + "CustomerSurname"); return View(); } The

How can I permanently fix the “EdmFunctionAttribute is obsolete” warning, which occurs after upgrading to EF6?

家住魔仙堡 提交于 2019-12-23 04:47:39
问题 I am getting the warning "EdmFunctionAttribute is obsolete" after I have upgraded a database first project from EF4 to EF 6.1.3: 'System.Data.Entity.Core.Objects.DataClasses.EdmFunctionAttribute' is obsolete: 'This attribute has been replaced by System.Data.Entity.DbFunctionAttribute.' C:\{myProjectPath}\DataContextEntityObjects.cs The attribute is used in various places like [EdmFunction("DataContext", "Split")] public IQueryable<Split_Result> Split(global::System.String rowData, global:

Issue extending the base EDMX model and calling the functions in the data model

懵懂的女人 提交于 2019-12-23 04:45:23
问题 I am writing a solution using MVC with scaffolding. It uses Entity Framework v6 and is database first in design. The base data model (ServiceAccountFilter) is extended by the data model (FilterModel). There is some logic in the FilterModel but the properties are all inherited from the base model. It seems as though the controller insists on using the base model. When I change the return to use the FilterModel, I get an error that the view requires the base model and then the functions in the

How to get data from the database into objectlists fast (with entity framework)

牧云@^-^@ 提交于 2019-12-23 04:22:32
问题 I'm using linq statements on entity framework objects to get data from the database into lists of objects. My problem is that the performance is abmyssal to say it nice. For a couple hundred or thousand of rows that I process it takes multiple seconds. I'm putting in a code example further below but first I want to explain WHY I'm putting the data I get into lists of objects and also I'm coming to my question after that: I'm putting the data into lists of objects to easily access the data and

OData + EF. Writing geography types

孤人 提交于 2019-12-23 03:35:09
问题 I have an Odata service which exposes an EF6 code first model. Some of these entities include DbGeography fields. I can GET these field, despite the DbGeography fields having quite an ugly serialized format, but I cannot figure out how to POST or PUT an entity to the service. The DbGeography type seems to struggle with deserialization. Can anyone provide an example or link for how to do this? 回答1: I've had this problem too. Its a bug apparently. Either two choices here - drop down to EF5 for

MVC - Select from Stored Procedure in Entity Framework

雨燕双飞 提交于 2019-12-23 02:54:35
问题 I am new to ASP.NET MVC. I should create a page where users enters an order for their shops by central warehouse. The products and amounts are listed by a stored procedure from database. I have to show rows in a gridview which are calculated by the stored procedure. I want to insert the changed data in a table in SQL after the user make changes on the gridview. Users can call the saved doc back and make changes on it and save it again. I can't build a strategy how that can be made. If I use