entity-framework-5

How to check if my SQL Server Express database exceeds the 10 GB size limit?

心已入冬 提交于 2020-04-08 18:22:05
问题 I am developing a web site, it uses SQL Server 2008 R2 Express for its database. And in testing, there is a lot of data and images stored into this database. According to wiki, the SQL Server Express edition has a 10 GB size limit. When I insert data and reach the limit, what exception will be thrown? Or, how do I detect the approaching limit problem by codes ? I use EF 5 with code-first approach to insert large data set. 回答1: In tests I have seen that: sp_spaceused won't work as expected, it

entity framework 5.0 .load method and .local property are missing from entity

試著忘記壹切 提交于 2020-03-04 23:01:27
问题 I'm using entity framework 5 and have two Visual Studio 2010 solutions. One is a small test solution with one project and one is a much larger solution with multiple projects where I'm doing the actual business application. The entities in the smaller solution have both the .Load() method and the .Local property. The entities in the larger solution have neither. I've referenced both system.data.entity and EntityFramework in the projects. I've compared the two solutions and can't figure out

Constructor on type 'System.Data.Entity.Infrastructure.SqlConnectionFactory' not found

纵饮孤独 提交于 2020-03-01 05:39:25
问题 I "upgraded" my PC from Windows 7 to Windows 8 yesterday, so now I'm using Visual Studio 2012, and opening my Visual Studio 2010 project. This project always worked fine, but it doesn't work in Visual Studio 2012. I had some weird errors, but I fixed those. Now I'm left with one error that I just can't fix and can't find anything about on Google: I get this exception: Failed to set Database.DefaultConnectionFactory to an instance of the 'System.Data.Entity.Infrastructure.SqlConnectionFactory,

Setting fetch size in entity framework

流过昼夜 提交于 2020-02-24 11:15:29
问题 I am converting ado.net code to use EF. In my ado.net code i set dataReader.FetchSize = command.RowSize * 1000 and that dramatically improves performance over the default fetch size . When I convert my code to EF, the performance is on par to ado.net code where I didn't specify fetch size, i.e. it's very slow over large records. Any way I could specify fetch size for retrieving records in EF? 回答1: You can set ODP.NET FetchSize in the Registry or the .NET config files when using Entity

X Already contains a definition Y with EntityFramework? (simple database)

让人想犯罪 __ 提交于 2020-02-11 06:27:07
问题 I have 3 tables in my MS SQL database and I have added a EntityFramework(latest) to my project where I have imported these 3 tables. The first problem was that no Entities was built so I changed "Code Genereation Strategy" from None to Default . After build I get X Already Contains a definition for Y on all properties of the entities. When looking closer it have generated a partial ex Users.cs and one partial User in in the MainModel.Designer.cs ? Why is it generating User.cs ? I have a

Receiving "The model backing the 'Context' context has changed… on Add-Migration after EF 5 upgrade

♀尐吖头ヾ 提交于 2020-02-03 04:49:05
问题 We are building an app using code-first migrations. We had been using Entity Framework 5.0.0 RC, and we updated our NuGet package for Entity Framework. The database has been in sync with the models context. Code first migrations have been working fine for months. When we modify our models, and try to add a migration, or even query for migrations, we receive the System.InvalidOperationException for the model backing changed. Well, obviously it has, I'm trying to add a migration. We're not sure

MVC4 - Membership - SQL Server Compact 4.0 - Exception: Unable to find the requested .Net Framework Data Provider

被刻印的时光 ゝ 提交于 2020-02-01 09:40:28
问题 The InitializeDatabaseConnection Method documentation says we can use the MVC 4 "Internet" template's generated membership functionality with SQLCE (SQL Server Compact 4.0 Local Database). I've used this template many times before and have never had a problem when I didn't fiddle with anything and simply used the localDb (the default) that is generated by the Entity Framework the first time we register a user. My requirement is to get the membership tables that are by default generated into

Incorrect value when saving enum

流过昼夜 提交于 2020-01-24 05:05:26
问题 I'm having a little difficulty getting Entity Framework 5 Enums to map to an integer column in a migration. Here's what the code looks like: [Table("UserProfile")] public class UserProfile { public enum StudentStatusType { Student = 1, Graduate = 2 } [Key] public int UserId { get; set; } public string UserName { get; set; } public string FullName { get; set; } public StudentStatusType Status { get; set; } } The migration looks like this: public partial class EnumTest : DbMigration { public

NullReferenceException in EF 5-6.1.1 with two navigation properties to the same type

眉间皱痕 提交于 2020-01-23 07:53:27
问题 I'd like to start with that I have a workaround for this issue - but I spent a few hours today figuring out the cause of the exception, so I'd thought I'd share Given two entities in the domain: public class User { public int Id { get; set; } public string Name { get; set; } } public class Ticket { public int Id { get; set; } public string Name { get; set; } public virtual User Owner { get; set; } public int? LockedByUserId { get; set; } public virtual User LockedByUser { get; set; }

Identity specification set to false

六眼飞鱼酱① 提交于 2020-01-21 06:51:00
问题 I am using EF5 and Code First to create database. When Entity has Id field , EF create such field as Primary Key in database and set Identity specification to true (auto generated value). How to set Identity specification to false by default ? 回答1: If you don't want to use identity keys you have several options. Option 1: You can globally turn off this feature by removing StoreGeneratedIdentityKeyConvention : public class YourContext : DbContext { protected override void OnModelCreating