I have built up a code-first model using Entity Framework 5.
The classes have several enums.
I started out by putting the model classes in a prototype ASP.NET MVC project.
I also added the
Database.SetInitializer(new DropCreateDatabaseAlways<dbType>());
command to the global.asax.cs file.
Running the MVC application in Visual Studio produced exactly the database schema I wanted in SQL Server (2008 R2). (with int value columns for the enums)
I then copied the model code to the solution where it will actually be used, which is split into several projects, one which has the EF code, another is the ASP.NET MVC part.
I also added the same Initializer to global.asax.cs
Now when I run the project, I do get the correct tables in the database, but for some strange reason, the enum columns are missing from the tables!
How do I make EF produce the enum columns?
Enum support is dependent on .NET 4.5 so it will only work when the project targets .NET 4.5.
Related
I've inherited an application, whose origins are lost in the mists of time. It's fairly obvious, based on DLL references and database tables, that the application is based on some edition / variant of ASP.NET Boilerplate. The question is exactly which one? The possibilities (I know of) are:
ASP.NET Boilerplate (free, open source)
ABP Framework (free, open
source)
ASP.NET Zero (licensed, source provided)
ABP Commercial
(licensed, source provided)
Whatever I have, it's obviously an old version since it's running on .NET Framework. (Latest versions of all of these application frameworks run on .NET Core.) We are working toward a phased transition to .NET Framework on .NET Core but one of the first things I picked up on is the incompatibility of my existing database structures for account authentication with the latest ABP Framework. One of the prerequisites for a phased transition is that a single database repository should accommodate account authentication from both the legacy system (as it does today) and the new system we are going to start constructing. I'd like to start working on various alternatives to bridge the gap from "here" to "there" but I'm handicapped by not even knowing where "here" is. I do know that the existing application is based on some variant of ASP.NET Boilerplate, but there are at least four of those. If you can help me pinpoint exactly what I've got, that will be immensely helpful. Thanks!
(All application ABP references are to DLLS. We don't have any ABP source code which might be useful for identification purposes.)
Here is a snapshot of the database tables, if that helps to make the identification:
Here is the one row within the abpEditions table:
Packages with the Abp prefix belong to ASP.NET Boilerplate or ASP.NET Zero. Packages with the Volo.Abp prefix belong to the ABP Framework or ABP Commercial. Since you have the Abp.Zero package, it appears to belong to ASP.NET Zero. The version information also appears to be 4.0.
I have a mvc application which I do not want to change. I also want to create an asp.net core web application with angular. I also have a ms sql database with and ado.net/edmx project.
Know I want to get my users, stored in the database. How can I reference my database project?
I have tried creating a new EF project with database first but that means changing other applications as well.
This is already a supported scenario. The only condition is that your ASP.NET Core project must target .NET Framework instead of .NET Core. See: https://learn.microsoft.com/en-us/aspnet/core/data/entity-framework-6?view=aspnetcore-2.2. For what it's worth, .NET Core 3.0 will support EF 6 natively, so eventually, you'll be able to target .NET Core again, if you choose this path.
Short of that, you should be able to create an EF Core library to work with your existing database which your ASP.NET Core project can then utilize. Since it's referencing the same database and not making any direct alterations to the schema, it should have no bearing on any other applications.
I'm trying to use SLQ server compact edition 4 together with entityframework 4.1 with code-first approach in a Windows form application.
In asp.NET MVC there are plenty of tutorials, but I can't find any help for windows form applications.
I did the following steps:
Created a windows form application
Created a new project class library called "library_database"
Created some classes and a DbContext
Created a app.config file in the project and a connection string to a database file with name equal to my DbContext class name
Now when I try to access my DbContext to add a new object, the application hangs and doesn't stop without returning any exception.
How is this possible?
Can you suggest me an approach, tutorial or anything to start?
Consider that I can use EF code-first with asp.NET MVC but I never tried with windows applications
Thanks!
I have this tutorial for WPF - also make sure the catch thrown exceptions when debugging! http://erikej.blogspot.com/2011/02/using-sql-server-compact-40-with.html
When looking at the documentation for WPF (e.g. for Selector.SelectedItem), I noticed that there are two XML naspaces: http://schemas.microsoft.com/winfx/2006/xaml/presentation and http://schemas.microsoft.com/netfx/2007/xaml/presentation.
What's the difference between the two, if any? Why are there two different namespaces that seem to point to the same group of .Net namespaces (do they really?)?
(guessing the answer)
the first version of WPF was called WinFX and was probably a separated project in MS organisation.
When WinFX joined the .Net Framework, MS has probably wished to keep the namespaces defines earlier for compatibility with existing work.
Later, new classes have been added, and MS decided to use a properly named namespace (NetFX is .Net Framework).
I'm currently working on an Xbox360 game. In this game I have lots of data stored in XML. Deserializing it through IntermediateSerializer in the XNA Game project is no problem, works like a charm. But since these structures stored in XML can be quite complicated I decided to make a simple editor for the stuff, so I (or maybe a less experienced user) could edit the objects visualy (animations, game stages etc) rather than having to write these data as XML. Then I would serialize it through the IntermediateSerializer and everything would be fine.
For this editor I created a WPF project, and referenced the Microsoft.Xna.Framework.Content.Pipeline.dll
Visual Studio recognizes the IntermediateSerializer class, and intellisense helpfully recommends to use the Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate namespace, but I keep getting the following error message:
The type or namespace name 'Pipeline' does not exist in the namespace 'Microsoft.Xna.Framework.Content' (are you missing an assembly reference?)
(I'm using XNA 4.0 and .NET 4)
Am I doing something wrong or is this just simply impossible?
Tenshiko
In your Application Properties ensure
that the Target framework is set to
.NET Framework 4.
By default a new WPF application targets the .NET Framework 4 Client Profile. The Client Profile is designed to reduce the download size of the .NET Framework for end users and excludes assemblies that are only used in development. In your case Microsoft.Xna.Framework.Content.Pipeline.dll depends on Microsoft.Build.Framework and Microsoft.Build.Utilities.v4.0 which are not available in the Client Profile.
It seems to me that you did set a target framework of your WPF application to ".NET Framework 4". It has to help.