entity-framework-5

How to update only one table for model from database with Entity Framework?

大憨熊 提交于 2019-12-04 08:03:21
问题 I have a model generated from db with Entity Framework. When I have any change in database, I update model from database to get the change in model. But this update is applied to all entities (tables) included in model. Now I add a new column in a table Tab1. I don't want to update model from database as some other changes that I don't want to include in model. I can add the new property in model for entity Tab1 manually. then it caused mapping error. So I need to update Model.Store for the

Entity Framework 5.0 Beta - will a DbContext code generation template be provided?

醉酒当歌 提交于 2019-12-04 07:35:10
I was working a bit ahead and planning for transition from EF 4.2 CTP to EF 5.0 and when "adding a code generation template" in VS11 + .NET 4.5 the DbContext template is no longer available. Any heads up on if one will be available and if not why (just curious)? Update: I see references to a DbContext template in the Enum tutorial, but yet I don't see the template in my VS11 project targeting .NET 4.5 with EF5.0 -pre installed. I see the other two V5.0 templates (EntityObject and Self-Tracking). Could it be a conflict with other installations, like in my case, Entity-Framework 4.2 CTP? I ran

A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name ''

为君一笑 提交于 2019-12-04 05:44:55
问题 I wonder if you could help. I get the above error when I call .Include() . It breaks when I include tblMemberships . this.dbContext.Configuration.LazyLoadingEnabled = false; List<tblCustomerInfo> customers = this.dbContext.tblCustomerInfoes.Include("tblUsers").Include("tblMemberships").ToList(); The reason is because the navigation property between tblCustomerInfo and tblMemberships does not exist. tblUsers is the link between the other two tables. Customer -- 1:* -- User -- 1:* -- Membership

Get entity facets and other metadata on runtime

江枫思渺然 提交于 2019-12-04 05:32:03
问题 I have .NET 4.0 WinForms Application, and I use Entity Framework 5 with Model First Approach. In VS EF Designer, I have created a dozen or so entities with a lot of scalar properties of String type, then in Properties Toolbar I have configured parameters (i.e. General parameters, Facets Parameters) for them, to fit DB requirements. In BL layer I am able to validate entity object in purpose to check whether it contains correct values, for example by using DbContext.Entry(Of T)(entity)

TextBoxFor() not generating validation markup

99封情书 提交于 2019-12-04 05:30:27
问题 I have a SQL Server 2012 in which I have AWARD table with two columns TITLE and MONTH. TITLE is varchar(256) and cannot be NULL. MONTH is int and can be NULL. With VS2012 Ultimate and EF 5.0.0, the TextBoxFor helper in MVC4 app is not producing validation (data-val="required" and data-val-required="required message") for the TITLE columne above, but in the same View, MONTH is getting the correct validation markup. The .edmx designer does show TITLE is NonNullable, BUTT, the automatically

Can I implement Entity Framework 5 TPT on Windows XP?

北慕城南 提交于 2019-12-04 05:15:29
问题 Examples of EF5 Table Per Type that I have found, such as this one use the [Table("tablename")] attribute to mark a class as defining a table. When I add this attribute I get errors: Error 1 The type or namespace name 'TableAttribute' could not be found (are you missing a using directive or an assembly reference?) E:\EShared\Syrius6\syrius_syrius\SBD.Syrius.DomainClasses\Classes.cs 599 6 DomainClasses Error 2 The type or namespace name 'TableAttribute' could not be found (are you missing a

Entity Framework AsNoTracking breaks call to Distinct

元气小坏坏 提交于 2019-12-04 05:04:58
I am trying to load a list of distinct colors from previously loaded list of products on a page. So to pull in the products I do this: var products = Products .Include(p => p.ProductColor) .ToList(); Then I do some processing on the products them I want to get a list of all of the distinct colors used by the products, so I do this: var colors = products .Select(p => p.ProductColor) .Distinct(); And this works great, however if I add a call to .AsNoTracking() to the original products call, I now get an entry in my color list for each entry in the product list. Why is there a difference in these

Entity Framework 5 does not clear navigation property

大城市里の小女人 提交于 2019-12-04 04:30:27
I've got this strange issue with Entity Framework 5 where I have a navigation property in one of my entities that I would like to set to null . But for some reason the property only gets cleared the second time I call this property: using (var db = new Entities()) { var vehicle = db.Vehicles.Single(v => v.Id == vehicleId); // After this call, ParkingBay is still set. vehicle.ParkingBay = null; // Only after this call, ParkingBay becomes null. vehicle.ParkingBay = null; db.SaveChanges(); } The Vehicle class that Entity Framework generates looks like this: public partial class Vehicle { public

Entity Framework 5 and Amazon RDS - “The underlying provider failed on Open.”

╄→гoц情女王★ 提交于 2019-12-04 04:03:43
问题 I have a C# / Entity Framework web application runs fine against a local SQL 2012 db. I copied the db out to a new RDS instance, and can access the db via Visual Studio and SQL Server Management Studio. I hav a unit test which authenticates the user and then attempts inserts a record in a table using an Entity Framework call -- dataContext.SaveChanges(). I get the following error: {"The underlying provider failed on Open."} {"No such host is known"} {"A network-related or instance-specific

Code first columns with type char(36)

我的梦境 提交于 2019-12-04 03:53:38
So I have a UserProfile model class as part of SimpleMembership. In it I need to store a legacy identifier that exists in another DB of type char(36) . I'd love to change this to something more sensible like a uniqueIdentifier but that's out of scope for today's activities. My current annotation creates a column nvarchar(36) [StringLength(36)] public string UserIdentifier{ get; set; } I'd like a column of char(36) instead. Is this possible? If you want to keep with Data Annotations, then just simply use: [StringLength( 36 )] [Column( TypeName = "char" )] public string UserIdentifier{ get; set;