entity-framework,asp.net-5,asp.net-mvc-6,entity-framework-7
The feature isn't implemented yet. Track its progress using issue #624. Here is a crude extension method you can use for now. public static int ExecuteSqlCommand(this RelationalDatabase database, string sql) { var connection = database.Connection; var command = connection .DbConnection.CreateCommand(); command.CommandText = sql; try { connection.Open(); return command.ExecuteNonQuery(); } finally...
Doubt this is currently supported (unsure if it eventually will or not).| I've tried to recreate your model with slight changes and when trying to create the database I get: System.NotSupportedException: The property 'PlaylistEntry`1MediaFile' cannot be mapped because it is of type 'MediaFile' which is currently not supported. Update 1...
c#,asp.net,asp.net-mvc,entity-framework-7
Problem is solved in this way: It turned out, that the exception "Login failed for user "Username"" raised, when before the first launch migration was not made by the hand. It automatically worked for "Code First" in the EF6, but in EF7 this feature was off. To perform migration you...
We haven't implemented data annotations yet. (See #107) You should be able to do it using the Fluent API. modelBuilder.Entity<MyEntity>().Ignore(e => e.NotMappedProperty); ...
c#,linq,asp.net-mvc-6,entity-framework-7
While it is a bit annoying, having to do that, for now I was able to solve the problem by renaming Permissions.PermissionId to Permissions.Id. Not a great solution and I have no clue why this affects anything (I added PermissionId as a key via Fluent API before), but it's working.
You are correct that #1151 is tracking this scenario. There are also some design meeting notes that summarize the API that will be available in EF7 - https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015.
osx,mono,asp.net-5,entity-framework-7
We will have a PostgreSQL and/or MySQL provider for EF7 (either delivered by our team or we'll work with a provider writer to help them build it). Work hasn't started on them yet though. We haven't been focusing on EF7 on Mono at this stage, so there are likely some...
asp.net-mvc-6,entity-framework-7
.ThenInclude() will chain off of either the last .ThenInclude() or the last .Include() (whichever is more recent) to to pull in multiple levels. To include multiple siblings at the same level, just use another .Include() chain. Formatting the code right can drastically improve readability. _dbSet .Include(tiers => tiers.Contacts).ThenInclude(contact => contact.Titre)...
c#,asp.net-mvc,code-first-migrations,entity-framework-7
Here is something that will get you on your way. As you know its still all beta and this is a little complex but the best we have at the moment. http://stoutcloud.com/geek-out-entity-framework-7/geek-ef7-reverse-engineering-first-look/ Just some commands to help along the way, since they changed a little since it changed to DNX....
database-migration,entity-framework-7
Data Annotations are not yet implemented in EF7. See issue #107.
c#,entity-framework,entity-framework-7
Here are my tips for working with navigation properties in Entity Framework 7. Tip 1: Initialize collections class Post { public int Id { get; set; } // Initialize to prevent NullReferenceException public ICollection<Comment> Comments { get; } = new List<Comment>(); } class Comment { public int Id { get;...
It turns out the culprit was IApplicationBuilder.UseDatabaseErrorPage. An upstream SQL error at startup was causing the Microsoft.AspNet.Diagnostics.Entity Database Error Page to render. The Database Error Page always queries the database's migrations to check if any migrations are pending, triggering the migrations system to attempt the query that produces the exception...
How are you trying to get the reference? Lazy loading at this point does not work in EF7. You'll have to do eager loading (dbContext.Materials.Include(m => m.UnitOfMeasure)) or the explicit version of that.
entity-framework,code-first-migrations,asp.net-5,entity-framework-7
Data annotation support is not yet implemented on EF7. You can track the work here https://github.com/aspnet/EntityFramework/issues/107
c#,asp.net,entity-framework,asp.net-5,entity-framework-7
I get it and add this code in my context: protected override void OnConfiguring(DbContextOptions options) { options.UseSqlServer(Startup.Configuration.Get("Data:DefaultConnection:ConnectionString")); } ...
c#,asp.net-mvc,entity-framework,asp.net-mvc-6,entity-framework-7
You must manually run migrations with EF7 from command line, or call ApplyMigrations from code, there is nothing automagic in EF7 (a deliberate decision) and after you change your model, create a new migration
Ok I found the solution : I changed all my beta1 dependencies to beta2 and it worked. I have another problem yet : the website doesn't show the Home page, I have a simple blank page ... EDIT 2 : Sorry for the inconvenience, it seems that the dependency "Microsoft.VisualStudio.Web.BrowserLink.Loader"...
c#,async-await,entity-framework-7,aggregateexception
As the MSDN page on Task<T> explains, all exceptions thrown by a Task are wrapped in AggregateException before being thrown to the awaiting code. If you're using multiple levels of async/await and not catching this exception at the lowest possible level, then each time it bubbles up another level, it'll...
entity-framework,entity-framework-7
If the EventTags are not being added to the database you may need to manually specify the EntityState for each tag. public int SaveEvent(Data.Models.Event evnt) { foreach(var tag in evnt.EventTags) { db.Entry(tag).State = EntityState.Added; } db.Events.Add(evnt); db.SaveChanges(); return evnt.EventId; } You might also want to update your class definition and...
The .Net 4.6(also called vNext) web project has a dependency on Microsoft.AspNet.Mvc. This pulls in a big tree of dependencies, the data annotations are under the package Microsoft.DataAnnotations for using Data annotation in your project use Microsoft.DataAnnotations in place of System.ComponantModel.DataAnnotations....
I just found a way to work around this. This seem to be happening with the latest version of the coreclr. Instead of calling dnvm install -r coreclr latest I called the following to switch from the latest version to beta4. dnvm use 1.0.0-beta4 -r coreclr When I call "dnx...
asp.net-5,asp.net-mvc-6,entity-framework-7
It doesn't look like this is currently supported, but it looks like someone saw this post and created the linked issue. The concept is a fairly complex bit of logic, and EF7 is very much in an early phase. .Net's GroupBy doesn't translate directly to SQL's GROUP BY until you...
entity-framework,asp.net-5,entity-framework-7
Because EF7 is still in pre-release, you won't find any documentation on it in MSDN articles yet; you'll need to look at the EF7 GitHub Wiki for any information. As you try out EF7 please bear in mind that this is a very early stage in the development of the...
asp.net-mvc,asp.net-5,asp.net-mvc-6,entity-framework-7
You must use ForSqlServer or ForRelational in the SqlServerPropertyBuilder to change the column name and in the modelBuilder to change the table name modelBuilder.Entity<IdentityUser>() .Property(o => o.Id) .ForSqlServer() .Column("User_Id") modelBuilder.Entity<IdentityUser>() .ForSqlServer() .Table("User") Update : For the beta 5 is not longer mandatory to use ForSqlServer...
c#,sql-server,entity-framework,entity-framework-7
If it returns entities, use the .FromSql() extension method on DbSet. You can even continue composing LINQ on top of it. var customers = db.Customers .FromSql("SELECT * FROM Customer") .Where(c => c.Name.StartsWith("A")); ...
Connect to (localdb)\mssqllocaldb in SQL Server Management Studio, delete the database there. I'm not sure why this step is required or why the migrations fails, however.
Currently, there is no MySQL support for EF 7. The following providers are currently available: SQLite https://www.nuget.org/packages/EntityFramework.SQLite SQL Server https://www.nuget.org/packages/EntityFramework.SqlServer There is also an alpha version of Postgres under development. https://github.com/npgsql/npgsql...
entity-framework,asp.net-5,entity-framework-7
There isn't really a way to do this yet. In general we strongly recommend against trying to upgrade an EF6 application to EF7 yet. EF7 is still very much pre-release. We will have some guidance on how to do this when we get closer to RTM. We may provide some...
It looks like the tutorial you're following is using an older version of the EF7 framework. EntityFramework 7 beta 4 no longer accepts any parameters to AddEntityFramework. It looks like beta 5 is still on this same track, too. I believe what you're looking for is this: // Register Entity...
asp.net,entity-framework-7,asp.net-identity-3
So, I've got an answer from MS: https://github.com/aspnet/Identity/issues/489 It's strange for me, but it looks that Identity is just for EF. Ok. I've found the way how to integrate my own users manager into the asp.net 5's app, so problem is solved: Asp.net vNext Cookie Authentication...
asp.net-5,asp.net-mvc-6,entity-framework-7
If you create a DBContext in a class library, to create migration you have to declare the ef command in the project.json of this class library. and run the k ef commmand for this project. { "version": "1.0.0-*", "dependencies": { "EntityFramework.SqlServer": "7.0.0-beta1", "EntityFramework.Commands": "7.0.0-beta1" }, "commands": { "ef": "EntityFramework.Commands" },...
code-first-migrations,asp.net-5,visual-studio-2015,entity-framework-7,dnx
Here is an approach that might work for you. If I run it in the folder of the shared project, it does not have access to the connection string specified in the startup.cs. Startup.cs I'm assuming that in your Startup.cs, you're specifying the connection string by accessing Configuration rather than...
asp.net,entity-framework,dbcontext,asp.net-5,entity-framework-7
I might be wrong, but my assumption is that when you create a new instance of DbContext in code, you are using the parameterless constructor that sets underlying connection string to some default value. However, DI-injected DbContext could be resolved using another constructor with different connection string passed in explicitly....
entity-framework,entity-framework-7,sqlite-net-extensions
You are correct, SQLite-Net Extensions caches the objects for recursive calls to avoid reference loops and handle inverse relationships, but it doesn't cache the objects between calls. SQLite-Net Extensions is just a thin layer over SQLite.Net, if integral reference is important for you, you can go back to manual queries...