entity-framework-6.1

Migrating SimpleMembership to Identity 2.0

一笑奈何 提交于 2019-12-01 05:17:01
This question has evolved so I've updated the title. This was the original title: Identity 2 UserManager.Find throws "Invalid object name 'dbo.ApplicationUser'" error I'm converting from SimpleMembership to Identity 2. I've ran the conversion script and refactored the various files for Identity use. I can build and run the app but when attempt to login an "Invalid object name 'dbo.ApplicationUser'" error is thrown on var user = UserManager.Find(vM.UserName, vM.Password); Account Controller: [RequireHttps] [Authorize] public class AccountController : Controller { private readonly IUserService

Migrating SimpleMembership to Identity 2.0

前提是你 提交于 2019-12-01 02:17:29
问题 This question has evolved so I've updated the title. This was the original title: Identity 2 UserManager.Find throws "Invalid object name 'dbo.ApplicationUser'" error I'm converting from SimpleMembership to Identity 2. I've ran the conversion script and refactored the various files for Identity use. I can build and run the app but when attempt to login an "Invalid object name 'dbo.ApplicationUser'" error is thrown on var user = UserManager.Find(vM.UserName, vM.Password); Account Controller:

Entity Framework 6 - Does not create tables when enabling Migrations

拟墨画扇 提交于 2019-11-30 20:30:39
In my application I enable Code First Migrations with some migrations, Also I use SQL Server Compact for integration test. When I run my tests, Entity Framework create an empty database and tries to run migration on that empty database and thrown The specified table does not exist. Based on this report I think usage of Migration in Entity Framework 6 has changed. I test all Database Initializer with Context.Database.Create(); but in all case tabale's never created. I don't know that this is EntityFramework's bug or not, but when I made rename the namespace of Migration Configuration class from

How to create spatial index using EF 6.1 fluent API

一曲冷凌霜 提交于 2019-11-30 19:55:58
Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API? Short answer- No, it is not. I have seen this tangentially referenced throughout blogs and have found no concrete examples of implementation. It seems to be related to the fact that spatial indexes are filtered indexes, which are not supported in Entity Framework. As support for my answer I constructed a POC console app with the most recent version of Entity Framework (6.1). I took the following steps Created a model that had a property of the type DbGeography Enabled automatic

store only date in database not time portion C#

二次信任 提交于 2019-11-30 17:43:32
I have a test class and an ExecutionDate property which stores only date but when we use [DataType(DataType.Date)] that also stores the time portion in database but I want only date portion. public class Test { [Key] public int Id { get; set; } [DataType(DataType.Date)] public DateTime ExecutionDate { get; set; } } Is any way to store only date on time portion in db using Entity Framework? Please help me.... I have added snapshot when use [DataType(DataType.Date)] that stores time portion 00:00 I want remove that I think you are trying to specify database column type. You could use data

Persist Entity Framework query cache

 ̄綄美尐妖づ 提交于 2019-11-30 10:02:10
I have an ASP.NET MVC 5 web-application and use EF 6.1 to access my DB. I have some rather complex LINQ queries which take up to 10s to compile, but then execute in a few milliseconds. EF does cache this queries fine and the second time the query is executed it returns within this few milliseconds. But this cache is not persisted so on every app-restart the query needs to be recompiled, which takes that 10s again. Is there a way to persist this query cache so it survives an app-restart? You can use compiled queries: see here or here static readonly Func<AdventureWorksEntities, Decimal,

Entity Framework 6 - Does not create tables when enabling Migrations

半城伤御伤魂 提交于 2019-11-30 04:58:14
问题 In my application I enable Code First Migrations with some migrations, Also I use SQL Server Compact for integration test. When I run my tests, Entity Framework create an empty database and tries to run migration on that empty database and thrown The specified table does not exist. Based on this report I think usage of Migration in Entity Framework 6 has changed. I test all Database Initializer with Context.Database.Create(); but in all case tabale's never created. 回答1: I don't know that this

How to create spatial index using EF 6.1 fluent API

我的未来我决定 提交于 2019-11-30 03:38:49
问题 Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API? 回答1: Short answer- No, it is not. I have seen this tangentially referenced throughout blogs and have found no concrete examples of implementation. It seems to be related to the fact that spatial indexes are filtered indexes, which are not supported in Entity Framework. As support for my answer I constructed a POC console app with the most recent version of Entity Framework (6.1)

EF performing a select on every insert with Identity column

只愿长相守 提交于 2019-11-29 17:16:37
I have noticed that when I insert with EF, it performs a select to find the next PK. I have a PK field with Identity set and auto-increment enabled. Here is the Query SELECT [ackId] FROM [dbo].[Acks] WHERE @@ROWCOUNT > 0 AND [ackId] = scope_identity() I happened to notice it as it was at the top of the Recent Expensive Queries List in SQL Manger Studio. It doesn't quite make sense that the query to find the PK is more expensive than the actual insert? Is this normal behaviour? Or is this behaviour causef by entity framework? Another issue I can think of. If EF is doing a select to get the

The specified type member 'UsersCount' is not supported in LINQ to Entities

半城伤御伤魂 提交于 2019-11-29 16:24:18
I have such POCO entity public class Product : Entity { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } [Required] [MaxLength(50)] public string Name { get; set; } public virtual ICollection<Order> Orders { get; set; } [NotMapped] public int UsersCount { get { return Orders.Count(); } } } Product access method public IQueryable<Product> GetAll() { return _context.Product.Include(I=>I.Orders); } When I load all products into View var model = _productService.GetAll().Select(p => new AdminProductViewModel { Active = p.Active, Id = p.Id, Name = p.Name, UsersCount = p