Menu
  • HOME
  • TAGS

db.database.ExecuteSQLCommand equivalent in EF 7

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...

Can these models be represented in EF7?

c#,entity-framework-7

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...

Entity Framework 7 and login failed

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...

How can I stop EF 7 mapping an entity property to a column?

entity-framework-7

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); ...

EF7: Foreign Keys are not generated when adding to Database Context

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.

DbSet.Include operator for ef7 accepting string path

entity-framework-7

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.

What use as Database for developing asp.net vNext + Entity Framework 7 on OSX

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...

Include several references on the second level

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)...

Entity Framework 7 Reverse Engineering ASP.NET 5

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....

DataAnnotation Atributes not applied in EF7

database-migration,entity-framework-7

Data Annotations are not yet implemented in EF7. See issue #107.

How to work with collections

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;...

In an ASP.Net vNext site, why does a migrations-related exception appear at startup?

c#,asp.net,entity-framework-7

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...

EF7 One to One relationships

c#,entity-framework-7

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.

Column name not reflecting on database

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

A relational store has been configured without specifying either the DbConnection or connection string to use

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")); } ...

Update Database after Model Changes - Entity Framework 7

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

ASP.NET vNext with EntityFramework.Core

asp.net-5,entity-framework-7

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"...

Many nested AggregateExceptions

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...

Adding a sub collection of new object and my new object into the database with Entity framework

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...

Unable to use data annotations

c#,entity-framework-7

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....

Cannot run migration on Entity Framework 7 beta4 in class library package

c#,entity-framework-7

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...

Entity Framework 7 group by

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...

ASP.NET vNext MVC and Entity Framework issues

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...

Override Default Identity Table Names

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...

Call stored procedure or run sql query?

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")); ...

EntityFramework 7 database already exists error on migrations

asp.net-5,entity-framework-7

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.

How to use EF7 with Mysql server?

entity-framework-7

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...

Upgrade from Entity Framework 6 to EF 7

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...

EF7 Beta 4 : AddEntityFramework dont accept argument (Configuration)

asp.net-5,entity-framework-7

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 5, indentity 3 and modular projects

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...

DbContext Not Found or A relational store has been configured without specifying either the DbConnection or connection string to use

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" },...

Entity Framework 7 Migration Scaffolding in Class Library with Configuration

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...

Dependancy Injected DbContext is empty after populating DbContext created with new (EF7, ASP.NET 5, vnext)

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....

SQLite.net Extensions loads the same entity multiple times rather than returning the same reference

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...