Reputation: 1549
EDIT :
In the original question, I mentioned ASP.NET 5. It DOES NOT target the future release of .Net Classic / .Net Core planned for 2021. The question was asked at the time of the first beta versions of .Net Core 1.0. At this time, it was named ASP.Net 5 / .Net vNext / DNX.
As such, in the original question, please understand version numbers as following :
I am starting a new project in ASP.Net 5 and ASP.NET MVC 6, running on DNX, and started out from the default MVC 6 template of Visual Studio 2015. My data layer uses Entity Framework 7 with the code-first approach.
My Web application project in then in the new approach : xproj file, referencing different json config files (project, solution, npm and bower managers).
As a long time .Net developer, I always had my Data Access Layer in an .Net Assembly projet (or several), then referenced into each of my client-side project (e.g. : a web application, a web API, console applications, or unit testing projects).
My questions are :
Upvotes: 1
Views: 1279
Reputation: 1549
Following this SO Question (What are my options for sharing code between DNX / ASP.NET 5 projects (project.json / xproj) and other C# projects (csproj) within a single solution?) - which is close to mine by the way - I decided to give a try to the default approch, which is a "Class Library (Package)" project.
I've had to change references to runtimes in order to have it working :
dnx451
and dnxcore50
.net451
and dotnet5.4
.I've had to change the latter to dnx451
and dnxcore50
to make everything work.
That remains an unexplained solution, because AFAIK, dnx451
and dnxcore50
should be now replaced by dnx451
and dnxcore50
, but I had to do the opposite, or my existing references (including "EntityFramework.Commands": "7.0.0-rc1-final"
) would be broken.
Anyway that solution is working, so for those interested in separating their EF logic in a shared project, I would recommand reading this article, which explains how to enable ef commands (migrations and database update) in a class library project : http://www.jerriepelser.com/blog/moving-entity-framework-7-models-to-external-project
Upvotes: 0
Reputation: 9391
It is possible but you have to manage this issue : https://github.com/aspnet/dnx/issues/3047
You have to remove any localization support by adding this to your Startup's configure method:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//...
var localizationOptions = new RequestLocalizationOptions()
{
SupportedCultures = new List<CultureInfo> { new CultureInfo("") },
SupportedUICultures = new List<CultureInfo> { new CultureInfo("") }
};
var invariantCulture = new RequestCulture(new CultureInfo(""), new CultureInfo(""));
app.UseRequestLocalization(localizationOptions, invariantCulture);
//...
}
Otherwise you will have this FileNotFoundException :
FileNotFoundException: Couldn't find file EntityFramework.resources.
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
Upvotes: 1