Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Issues with inserting Initial data #1826


User avatar
0
gregarmstrong created

Hi there,

We have had the ASP.NET Core codebase setup from ASP.NET Zero.

On running the application it created all tables required using code first approach, however it did not insert the data in the table as initial data.

Due to this we are getting an error while running application as "Default language is not set".

If we try to use "update-database" to run seed method, receives following error:

Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\laxman.g.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:718 char:5

  • $domain.SetData('project', $project)
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : SerializationException

Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\laxman.g.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:719 char:5

  • $domain.SetData('contextProject', $contextProject)
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : SerializationException

Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\Users\laxman.g.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:720 char:5

  • $domain.SetData('startUpProject', $startUpProject)
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : SerializationException

System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName) at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory) at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName) at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Object reference not set to an instance of an object.

Any help in this regard is much appreciated.


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    For Core template classic Update-Database command does not work. In order to run migrations and seed method follow the steps below.

    1. Open command prompt
    2. navigate to EntityFramework project directory in your solution on command prompt
    3. run command "dotnet ef database update"

    This information should be displayed when you download the project but it's very possible to miss that :). Please let us know if you have any problems.

  • User Avatar
    0
    gregarmstrong created

    Thanks for your response.

    However when we use the command "dotnet ef database update" getting following error

    Project Progressive_care.Core (.NETFramework,Version=v4.6.1) was previously compiled. Skipping compilation. Project Progressive_care.EntityFramework (.NETFramework,Version=v4.6.1) was previously compiled. Skipping compilation. No DbContext was found in assembly 'Progressive_care.EntityFramework'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

    I have verified that we do have DbContext in the 'Progressive_care.EntityFramework'

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you try after a rebuild ? If it does not work, can you send your project to us (to <a href="mailto:[email protected]">[email protected]</a>).

    Thanks.