Jump to content
  • 0

Error server when development, edit source code??


nvh

Question

I want to add a new random stat for item, but get this error. please help me

a640f629112d97d68b4646a9cd9830f9.png

 

line code when debug server.exe

line code when debug server.exe

public ICollection<string> PendingMigrations =>
            Database?.GetPendingMigrations()?.ToList() ?? new List<string>();

maybe because the database. I don't know how to fix it!! thank you!

 

Link to comment
Share on other sites

Recommended Posts

  • 1

I'm not sure if that's all you added to the item, as I'm seeing property names that are definitely not on the base engine. (StatVatCong?)

 

Either way I think there's two problems going on here. One is causing the current issue and the other will be an issue after.

 

It appears your database file is corrupt. Do you have a recent back up you can try and restore?

Link to comment
Share on other sites

  • 0

The first question is, what did you add to the item class? And did you edit anything other than this and the editor to do so?

 

And then my second question would be did you generate a migration after editing the item class?

 

Third, did you manually edit the database?

 

That's not an error that should regularly occur so I'm curious what has caused it to happen.

Link to comment
Share on other sites

  • 0
31 minutes ago, Cheshire said:

The first question is, what did you add to the item class? And did you edit anything other than this and the editor to do so?

 

And then my second question would be did you generate a migration after editing the item class?

 

Third, did you manually edit the database?

 

That's not an error that should regularly occur so I'm curious what has caused it to happen.

your ques

1.  A text input (like Statbonus range) but it's only random Damage. Besides that, there's nothing else!

 

2. i don't know how to do that. What is that?

 

3. one time, but i did ctrl + z

 

line code when debug server.exe

public ICollection<string> PendingMigrations =>
            Database?.GetPendingMigrations()?.ToList() ?? new List<string>();

 

thank you for quest

Link to comment
Share on other sites

  • 0
45 minutes ago, Cheshire said:

Tôi không chắc liệu đó có phải là tất cả những gì bạn đã thêm vào mục hay không, vì tôi thấy tên tài sản chắc chắn không có trên động cơ cơ sở. (StatVatCong?)

 

Dù bằng cách nào tôi nghĩ có hai vấn đề đang diễn ra ở đây. Một là gây ra vấn đề hiện tại và cái kia sẽ là một vấn đề sau đó.

 

Có vẻ như tệp cơ sở dữ liệu của bạn bị hỏng. Bạn có bản sao lưu gần đây mà bạn có thể thử và khôi phục không?

Thank you!

Thank you!

How to edit .db file. Can i add StatVatCong to database?

 

Link to comment
Share on other sites

  • 0

Okay, editing the database is not something you would normally do on your own unless you want to cause some pretty serious issues in the future with the ability to upgrade your database to a new version as we release updates for the source.

 

Your best bet would be to add a migration yourself. How to do so is described over here: https://docs.freemmorpgmaker.com/en-US/developer/advanced/database.html#creating-a-migration

 

(For items, you'll want to add one to the GameContext)

 

Once the migration file is created you can simply upgrade your database the same way you'd do after we release an update.. make a backup, run the server and type in READY.

 

If you've set everything up correctly it'll work without errors. The Entity Framework can be a little fiddly so you may need to change a thing or two depending on how complex your changes are.

Link to comment
Share on other sites

  • 0
5 minutes ago, Cheshire said:

Okay, editing the database is not something you would normally do on your own unless you want to cause some pretty serious issues in the future with the ability to upgrade your database to a new version as we release updates for the source.

 

Your best bet would be to add a migration yourself. How to do so is described over here: https://docs.freemmorpgmaker.com/en-US/developer/advanced/database.html#creating-a-migration

 

(For items, you'll want to add one to the GameContext)

 

Once the migration file is created you can simply upgrade your database the same way you'd do after we release an update.. make a backup, run the server and type in READY.

 

If you've set everything up correctly it'll work without errors. The Entity Framework can be a little fiddly so you may need to change a thing or two depending on how complex your changes are.

then I won't touch the .db file anymore. but if not fix db what should i do with StatVatCong??

 

Link to comment
Share on other sites

  • 0

If you undo changes you've made manually to it and let the migration upgrade the database it should add that field on its own.

 

Basic procedure for adding your own properties and fields to the database boils down to this:

1. Make code changes to relevant classes.

2. Generate new Migration.

3. Compile server.

4. Backup database.

5. Run server and upgrade database.

 

The Entity Framework (our database layer) will handle the scary stuff itself so you can for the most part focus on making your features with little worry about the database.

Link to comment
Share on other sites

  • 0
12 hours ago, Cheshire said:

If you undo changes you've made manually to it and let the migration upgrade the database it should add that field on its own.

 

Basic procedure for adding your own properties and fields to the database boils down to this:

1. Make code changes to relevant classes.

2. Generate new Migration.

3. Compile server.

4. Backup database.

5. Run server and upgrade database.

 

The Entity Framework (our database layer) will handle the scary stuff itself so you can for the most part focus on making your features with little worry about the database.

Microsoft.Data.Sqlite.SqliteException
  HResult=0x80004005
  Message=SQLite Error 1: 'no such column: i.StatVatCong'.
  Source=Microsoft.Data.Sqlite
  StackTrace:
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.<PrepareAndEnumerateStatements>d__62.MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__17`2.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
   at Intersect.Server.Database.DbInterface.LoadGameObjects(GameObjectType gameObjectType) in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Database\DbInterface.cs:line 704
   at Intersect.Server.Database.DbInterface.LoadAllGameObjects() in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Database\DbInterface.cs:line 603
   at Intersect.Server.Database.DbInterface.InitDatabase(ServerContext serverContext) in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Database\DbInterface.cs:line 284
   at Intersect.Server.Core.Bootstrapper.PostContextSetup() in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Core\Bootstrapper.cs:line 227
   at Intersect.Server.Core.Bootstrapper.Start(String[] args) in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Core\Bootstrapper.cs:line 55

  This exception was originally thrown at this call stack:
    [External Code]
    Intersect.Server.Database.DbInterface.LoadGameObjects(Intersect.Enums.GameObjectType) in DbInterface.cs
    Intersect.Server.Database.DbInterface.LoadAllGameObjects() in DbInterface.cs
    Intersect.Server.Database.DbInterface.InitDatabase(Intersect.Server.Core.ServerContext) in DbInterface.cs
    Intersect.Server.Core.Bootstrapper.PostContextSetup() in Bootstrapper.cs
    Intersect.Server.Core.Bootstrapper.Start(string[]) in Bootstrapper.cs

in https://docs.freemmorpgmaker.com/en-US/developer/advanced/database.html#creating-a-migration

Tut: Now build your server. Building with the NoFody configuration will generate a bunch of required dlls.

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS1566	Error reading resource 'Intersect.Server.network.handshake.bkey.pub' -- 'Could not find a part of the path 'E:\DuAnGame\Intersect\TV(Delop)\build\nofody\keys\network.handshake.bkey.pub'.'	Intersect.Server	E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\CSC	1	Active

 

Link to comment
Share on other sites

  • 0

That first error only happens if you actually run the server without having a migration. You're supposed to build it not run it.

 

As for the second one, manually rebuild the network project and that should solve it. If it doesn't you may have to copy the file to the location it asks for from your debug folder.

Link to comment
Share on other sites

  • 0
36 minutes ago, Cheshire said:

That first error only happens if you actually run the server without having a migration. You're supposed to build it not run it.

 

As for the second one, manually rebuild the network project and that should solve it. If it doesn't you may have to copy the file to the location it asks for from your debug folder.

i read how to migration but i really don't understand. I'm so bad :(

Link to comment
Share on other sites

  • 0

Unfortunately it's required to really make use of the database. And outside of the steps listed on the documentation there's no extra steps to it.

 

It's a little fiddly the first time you do it but after you get how to do it it's pretty easy.

Link to comment
Share on other sites

  • 0
29 minutes ago, Cheshire said:

Unfortunately it's required to really make use of the database. And outside of the steps listed on the documentation there's no extra steps to it.

 

It's a little fiddly the first time you do it but after you get how to do it it's pretty easy.

i am generating random variable like "StatGrowth". can i add it like this?

e675868cdb37759a082936010687e447.png

Link to comment
Share on other sites

  • 0

No. Not manually, that's what the migration should do for you.

All you need to edit is the Item class itself, then create a migration.

Any edits you make to the database and its files yourself are likely to cause problems.

Link to comment
Share on other sites

  • 0
8 minutes ago, Cheshire said:

No. Not manually, that's what the migration should do for you.

Thanks very much! my love. I succeeded first time!!!

but 

System.NotSupportedException
  HResult=0x80131515
  Message=SQLite does not support this migration operation ('DropPrimaryKeyOperation'). For more information, see http://go.microsoft.com/fwlink/?LinkId=723262.
  Source=Microsoft.EntityFrameworkCore.Sqlite
  StackTrace:
   at Microsoft.EntityFrameworkCore.Migrations.SqliteMigrationsSqlGenerator.Generate(DropPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder)
   at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)
   at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql(Migration migration)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Intersect.Server.Database.DbInterface.InitDatabase(ServerContext serverContext) in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Database\DbInterface.cs:line 250
   at Intersect.Server.Core.Bootstrapper.PostContextSetup() in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Core\Bootstrapper.cs:line 227
   at Intersect.Server.Core.Bootstrapper.Start(String[] args) in E:\DuAnGame\Intersect\TV(Delop)\Intersect.Server\Core\Bootstrapper.cs:line 55

 

Link to comment
Share on other sites

  • 0
1 minute ago, Cheshire said:

Yeah migrations generate stuff that's unsupported sometimes. Not sure why it's dropping the primary key though..

 

Can you post the migration file here so I can see what it's done?

using Microsoft.EntityFrameworkCore.Migrations;

namespace Intersect.Server.Migrations.Game
{
    public partial class AddingItems_random_stat : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_Items",
                table: "Items");

            migrationBuilder.RenameTable(
                name: "Items",
                newName: "ItemBase");

            migrationBuilder.AddColumn<int>(
                name: "StatAmor",
                table: "ItemBase",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "StatMaCong",
                table: "ItemBase",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "StatSpeed",
                table: "ItemBase",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "StatVatCong",
                table: "ItemBase",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddPrimaryKey(
                name: "PK_ItemBase",
                table: "ItemBase",
                column: "Id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_ItemBase",
                table: "ItemBase");

            migrationBuilder.DropColumn(
                name: "StatAmor",
                table: "ItemBase");

            migrationBuilder.DropColumn(
                name: "StatMaCong",
                table: "ItemBase");

            migrationBuilder.DropColumn(
                name: "StatSpeed",
                table: "ItemBase");

            migrationBuilder.DropColumn(
                name: "StatVatCong",
                table: "ItemBase");

            migrationBuilder.RenameTable(
                name: "ItemBase",
                newName: "Items");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Items",
                table: "Items",
                column: "Id");
        }
    }
}

 

Link to comment
Share on other sites

  • 0
5 minutes ago, Cheshire said:

What else did you change? It really shouldn't be trying to rename the Items table.

 

Did you change this line?

https://github.com/AscensionGameDev/Intersect-Engine/blob/40eb62cab66ad1efff3adf64e761e337d3b0f44e/Intersect.Server/Database/GameData/GameContext.cs#L58

Yep! I make new line like “        public DbSet<ItemBase> Items { get; set; }”

but “Items” is “Items_random_stat”. 

StatVatCong, StatMaCong... are variables like StatGrowth 

 

Link to comment
Share on other sites

  • 0
4 hours ago, Cheshire said:

I don't think you did that right, can you show a screenshot?

I'm pretty sure all you had to really do was add the new properties to the itembase class and not touch the rest of the data structure.

Can i using

Add-Migration -Context GameContext AddingItems
Link to comment
Share on other sites

  • 0

I'm not sure what you're trying to do with that command? Whatever it is you've changed appears to have broken the Database structure and is now renaming the Items table causing issues.

 

Personally, I think it might be easier to revert back to a base source branch and start over.

Add the new properties to the ItemBase class, change your editor and add the method that calculates the new random stats you've added.

After that create a new migration.

Link to comment
Share on other sites

  • 0
17 minutes ago, Cheshire said:

I'm not sure what you're trying to do with that command? Whatever it is you've changed appears to have broken the Database structure and is now renaming the Items table causing issues.

 

Personally, I think it might be easier to revert back to a base source branch and start over.

Add the new properties to the ItemBase class, change your editor and add the method that calculates the new random stats you've added.

After that create a new migration.

because it belongs to ItemsBase so I don't know how to migration. pls help me in the next step

04011076b46e15e1b89cbfda24af11fa.png

Link to comment
Share on other sites

  • 0
1 minute ago, Cheshire said:

If those screenshots are all you've changed it should be fine.

But since your migration is wrecking the Items table I'm not sure that's all you've done.

I deleted and clone again. These are the only things that I do. pls Can you help me the next step (migration)?

Link to comment
Share on other sites

  • 0

Right, in that case using the Add-Migration command should do fine like this:

 

Add-Migration -Context GameContext AddRandomStatToItems

 

Then switch back to debug mode and compile/run as usual and it should upgrade your database.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...