entity-framework-6

OData + EF. Writing geography types

别来无恙 提交于 2019-12-06 15:52:42
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? I've had this problem too. Its a bug apparently. Either two choices here - drop down to EF5 for the old System.Data.Entity.DbGeography (rather than System.Data.Entity.Spatial.DbGeography ), or wait until

How can I create a MetadataWorkspace using metadata loading delegates?

半腔热情 提交于 2019-12-06 15:37:14
问题 I followed this example Changing schema name on runtime - Entity Framework where I can create a new EntityConnection from a MetaDataWorkspace that I then use to construct a DbContext with a different schema, but I get compiler warnings saying that RegisterItemCollection method is obsolete and to "Construct MetadataWorkspace using constructor that accepts metadata loading delegates." How do I do that? Here is the code that is working but gives the 3 warnings for the RegsiterItemCollection

Entity framework 6 - Blocked time waiting for a connection

喜你入骨 提交于 2019-12-06 15:36:26
Below is a picture of some profiling with Azure Application Insights. It comes from the execution of that simple request: public HttpResponseMessage Login(LoginRequest loginRequest) { var t = new DependencyTracker(); using (var context = t.TrackDependency(() => new SocialDbContext(), "NewContext")) { var user = t.TrackDependency(() => context.Users.AsNoTracking().SingleOrDefault(x => x.Email == loginRequest.Id || x.Name == loginRequest.Id), "GetUser"); if (user == null) return t.TrackDependency(() => Request.CreateResponse(HttpStatusCode.BadRequest, ApiError.WrongCredentials),

Entity Framework 6 with Sharepoint 2013

岁酱吖の 提交于 2019-12-06 15:04:37
问题 I tried without success to get a SharePoint 2013 application page or web part to work with Entity Framework 6 (6.0.1 to be exact - the version installed into Visual Studio 2012 by default using NuGet at time of writing). My code was very simple for test purposes, just reading data from one table. I could install the package just fine, create models, see that the they were properly configured etc, no problem - but whenever I tried to load the page I got the error: Event code: 3008 Exception

Insert/Update data to Many to Many Entity Framework . How do I do it?

让人想犯罪 __ 提交于 2019-12-06 14:01:24
问题 My context is => Using this model via Entity Framework code 1st, data table in database becomes => 1) User Table 2) Role Table 3) UserRole Table - A new linked table created automatically Model for User is => Model for Role is => and my O Data query for inserting record for single User/Role table working properly Now, what query should I write, when I want to Insert record to UserRole table can someone have any idea 回答1: // Fetch the user. var user = await metadataManagentClient.For<User>()

Define SQL table primary key as case sensitive using Entity Framework Code First

夙愿已清 提交于 2019-12-06 13:31:08
Is it possible to define a SQL case sensitive primary key in entity framework code first? I know that by default SQL is case insensitive when it comes to strings, just to be clear I don't want to change the entire DB definition to case sensitive, just one table column (primary key). I'm getting data from an external API which sends the data with case sensitive primary keys ('a' and 'A' are different records), I know I can modify them and save them differently in my DB, but this will also require me to be consistent about it everywhere in my code. That's defiantly possible, but I would rather

Changing EF6 source code for conversion of short to bool

怎甘沉沦 提交于 2019-12-06 13:13:48
What is the feasibility of modifying the mapping code to convert a short of value zero or non-zero to false or true, if the boolean destination property is marked with an attribute in the POCO model? I mean, this is supposed to be one of the advantages of EF being open sourced, and would be for in house use only. Any tips on where in the code I would look would be appreciated, but this question is really more general and I'd like to hear anything anyone has to say on this. With regard to the General comments please. I dont know to make the EF change, but dealing with similar issues is not an

Entity Framework multiple aggregation performance

痞子三分冷 提交于 2019-12-06 12:29:26
I have a question about entity framework query building. Schema I have a table structure like this: CREATE TABLE [dbo].[DataLogger]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [ProjectID] [bigint] NULL, CONSTRAINT [PrimaryKey1] PRIMARY KEY CLUSTERED ( [ID] ASC ) ) CREATE TABLE [dbo].[DCDistributionBox]( [ID] [bigint] IDENTITY(1,1) NOT NULL, [DataLoggerID] [bigint] NOT NULL, CONSTRAINT [PrimaryKey2] PRIMARY KEY CLUSTERED ( [ID] ASC ) ) ALTER TABLE [dbo].[DCDistributionBox] ADD CONSTRAINT [FK_DCDistributionBox_DataLogger] FOREIGN KEY([DataLoggerID]) REFERENCES [dbo].[DataLogger] ([ID]) CREATE TABLE

Set identity to the previous created column during migration

风格不统一 提交于 2019-12-06 12:27:40
I have a project with the CodeFirst database (Entity Framework 6) and two migration steps. Database is updated automatically by using this code in Application_Start in Global.asax: Database.SetInitializer( new MigrateDatabaseToLatestVersion<MyDBEntities, MyNamespace.Configuration>()); First migration step is creating the tables: CreateTable( "dbo.GalleryAlbum", c => new { Id = c.Int(nullable: false), //other columns..... }) .PrimaryKey(t => t.Id); CreateTable( "dbo.GalleryPics", c => new { Id = c.Int(nullable: false), //other columns..... }) .PrimaryKey(t => t.Id) .ForeignKey("dbo.GalleryAlbum

Entity Framework - Non Key Relationships

自作多情 提交于 2019-12-06 12:00:57
问题 Problem I have a situation whereby I need to use Entity Framework 6, Code First, with a legacy database structure which cannot be changed. The database has a very generic table which stores text based data alongside some non key data which can be used to relate the record back to another table. To illustrate: Assume the Notes table has a model as follows: [Table("Notes")] public class Notes { [Key] public int RecordId { get; set; } [Required] public string RelatedTableName { get; set; }