How can set a default value constraint with Entity Framework 6 Code First?

Unfortunately the answer right now is ‘No’. But you can vote for Better support for default values EDIT 30 Mar 2015: It’s coming in EF7… Support database default values in Code First EDIT 30 Jan 2017: General support for default database values is part of EF Core (the new name for EF7)… Default values EDIT … Read more

OData V4 modify $filter on server side

Remove [EnableQuery] attribute, your scenario should work, because after using this attribute, OData/WebApi will apply your original query option after you return data in controller, if you already apply in your controller method, then you shouldn’t use that attribute. But if your query option contains $select, those code are not working because the result’s type … Read more

How does the SQLite Entity Framework 6 provider handle Guids?

It appears that this was resolved in 1.0.95 however broken again in 1.0.97. The solution is to set the BinaryGUID property on the connection string to true and set the following environment variable (before you make the connection) Environment.SetEnvironmentVariable(“AppendManifestToken_SQLiteProviderManifest”,”;BinaryGUID=True;”); Data Source=c:\mydb.db;Version=3;BinaryGUID=True; https://www.connectionstrings.com/sqlite/

How to inject UserManager & SignInManager

Prerequisites Start a new MVC5 application using the MVC template. This will install all the necessary dependencies as well as deploy the Startup.Auth.cs file which contains the bootstrap code for Microsoft.AspNet.Identity (it als includes the all the references for Microsoft.AspNet.Identity). Install the following packages and update them to the latest afterwards. Install-Package Ninject Install-Package Ninject.MVC5 … Read more

How to implement Multi-tenant User Login using ASP.NET Identity

I’ve now got a working solution that I’ve shared in a GitHub repository: https://github.com/JSkimming/AspNet.Identity.EntityFramework.Multitenant The extensibility required to support multi-tenancy is not possible with the 1.0.0 release of Microsoft.AspNet.Identity.EntityFramework (at least not without a lot of custom work), but is available in the 1.1 alpha release currently available through the Nightly ASP.NET Web Stack NuGet … Read more

How do I remove underscore of foreign key fields in code first by convention

I finally found an answer for this, by writing a custom convention. This convention works in EF 6.0 RC1 (code from last week), so I think it’s likely to continue to work after EF 6.0 is released. With this approach, the standard EF conventions identify the independent associations (IAs), and then create the EdmProperty for … Read more

Enable Entity Framework migrations in Mono

All of the Entity Framework Migrations commands are just thin wrappers over an underlying API. To enable migrations, simply create a new class that derives from DbMigrationsConfiguration<TContext> in your project. For Add-Migration use code similar to the following. var config = new MyMigrationsConfiguration(); var scaffolder = new MigrationScaffolder(config); var migration = scaffolder.Scaffold(“Migration1”); File.WriteAllText(migration.MigrationId + “.cs”, … Read more