entity-framework-6

EntityFramework 6 Alpha 2 & MySQL Connector/NET 6.6.4

别等时光非礼了梦想. 提交于 2019-12-04 12:46:07
The 6.6.4 MySQL .NET connector apparently has support for EF6. I've upgraded from EF5 and .NET 4 to EF6 alpha2 and .NET 4.5. I've recreated the ADO.NET Entity Data Model since upgrading. Upon doing anything to the database it throws up an exception message saying; ItemModel.ssdl(2,2) : error 0152: No Entity Framework provider found for 'MySql.Data.MySqlClient' ADO.NET provider. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. Currently my app.config file contains; <?xml

Splitting DbContext into multiple contexts with overlapping DbSets

五迷三道 提交于 2019-12-04 12:31:24
问题 I have a DbContext that houses +80 entities at the moment with only 4 of the main modules done, but there are 3 more to go, and they are quite bigger so it will get up to 150 easy. I think it is the perfect time to divide the contexts. Every module uses it's own entities and will get it's own context, but there is a group of entities that are used by all of the modules, so here is mu question: Should I have one MainContext that will have all of the overlapping entities but then: What will

How do I use Entity Framework 6 with MySQL in ASP.NET 5?

…衆ロ難τιáo~ 提交于 2019-12-04 11:50:12
I have an existing site that uses ASP.NET MVC 4, Entity Framework 6 and MySQL. I'm trying to upgrade it to ASP.NET 5, but want to continue using Entity Framework 6 as Entity Framework is missing some features and does not yet support MySQL. How do I use EF6 in ASP.NET 5? Since Web.config is no longer used with ASP.NET 5, you need to use code-based configuration to configure it instead. To do so, create a new class that inherits from DbConfiguration: public class MyDbConfiguration : DbConfiguration { public MyDbConfiguration() { // Register ADO.NET provider var dataSet = (DataSet

After upgrade to EF6 - The property cannot be configured as a navigation property

守給你的承諾、 提交于 2019-12-04 11:43:37
I have a following class: [Table("TagSource")] public class TagSource { public TagSource() { this.DataSources = new HashSet<DataSource>(); } [Key] public int TagSourceId { get; set; } ... public bool IsHistorical { get; set; } public Nullable<int> ModifiedEntryId { get; set; } ... public int? AttachedTagSourceId { get; set; } [ForeignKey("AttachedTagSourceId"), InverseProperty("TagSourceId")] public virtual TagSource AttachedTagSource { get; set; } [ForeignKey("ModifiedEntryId"), InverseProperty("TagSourceId")] public virtual TagSource ModifiedEntry { get; set; } } I was using Entity Framework

IRepository and Unit Of Work vs Eager Loading

江枫思渺然 提交于 2019-12-04 11:39:48
I know having a Unit Of Work is having an abstraction on top of an abstraction ( DbContext ) and surely that is an anti-pattern, or at least is not necessary. I have the following problem: I have a generic IRepository like so: public interface IGenericRepository<TEntity> where TEntity : class { IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = ""); TEntity GetByID(object id); void Insert(TEntity entity); void Delete(object id); void Delete(TEntity entityToDelete); void Update

AspNet.Identity Custom User and Custom Role should be simple; what am I missing?

强颜欢笑 提交于 2019-12-04 10:45:18
Using examples from http://www.asp.net/identity I've gotten this far. The RoleManager works flawlessly and I treat the UserManager the same. I think everything is correct, but I can't seem to new up a UserManager correctly in a controller. What is wrong? At one point, I was successfully getting the UserManager to work but was getting an EntityValidationError saying "Id is required" when creating a new user with UserManager.Create(user, password); as posted in this question UserManager.Create(user, password) thowing EntityValidationError saying Id is required? So after some time of hit and miss

The type RoleStore<IdentityRole> is not assignable to service IRoleStore<IRole>

风流意气都作罢 提交于 2019-12-04 07:33:35
I'm trying to set up dependency injection with Autofac for project using MVC5 and EF6. I'm having a hard time figuring out how to decouple correctly the EntityFramework.RoleStore<EntityFramework.IdentityRole> implementation. I would like have dependency only on Identity.IRoleStore<Identity.IRole> but I'm aware that for generic classes I need to specify the concrete implementation, not the interface. This is what I tried: builder.RegisterType<IdentityRole>().As<IRole>(); builder.RegisterType<RoleManager<IRole>>(); builder.RegisterType<RoleStore<IdentityRole>>().As<IRoleStore<IRole>>(); builder

How to Update Employee and Identity User with one to one/zero relation

≡放荡痞女 提交于 2019-12-04 07:11:01
问题 I am trying to update employee record and want to update identity user too. If i update Identity User first separately For Example: UserManager.Update(user); Context.Entry(employee).State = System.Data.Entity.EntityState.Modified; Context.SaveChanges(); and then update the employee. maybe it is possible identity user updates with success but employee update process gets an error. so IdentityUser is updated now but the employee is not. how to handle this situation. please guide. public class

EF6 - Using the await keyword with the Where() clause

£可爱£侵袭症+ 提交于 2019-12-04 06:47:00
I am coding a MVC 5 internet application with entity framework 6 and have a question in regards to using the await keyword when using the .Where() clause. Here is my code that works: public async Task<Account> GetAccount(string userName) { if (Session[userName] == null) { Account account = db.accounts.Where(a => a.userName.Equals(userName)).FirstOrDefault(); if (account == null) { //log out return null; } Session[userName] = account; } return Session[userName] as Account; } I am wanting to use the await keyword when retrieving the Account object as follows: Account account = await db.accounts

Azure deployment: error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace

 ̄綄美尐妖づ 提交于 2019-12-04 06:41:28
问题 I'm continuously deploying my Azure Web App as usual (using Visual Studio Community 2019) but now I'm getting the following error. (Also, I've already seen this question: The default XML namespace of the project must be the MSBuild XML namespace, but I'm only getting this error in the logs in the Deployment Centre of my Azure Web App, and that question relates to Visual Studio 2017.) "WebApp" is the name of the solution: D:\home\site\repository\packages\EntityFramework.6.3.0\build