Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 12: Creating a class library for entity models using SQLite' help needed. #70

Open
Jammerref2015 opened this issue May 10, 2023 · 4 comments

Comments

@Jammerref2015
Copy link

In chapter 12. I am trying to follow the 'Creating a class library for entity models using SQLite'. I follow the 10 steps but I am not getting any Classes generated. I have NorthwindContext.cs created. Am I doing something wrong? Missing a step? I have the DB connected, I can see the data in SQLite/SQLserver Compact Toolbox.

@markjprice
Copy link
Owner

markjprice commented May 11, 2023

Mostly likely the dotnet-ef tool cannot find the database file in the location specified. If the database file is missing, then the SQLite database provider will create an empty database file and since it is empty, you get a DbContext class generated but not any entity model classes.

If you are doing Chapter 12, then you would have had to run the dotnet-ef tool in Chapter 10 on page 453 as well. Did you get it to work then? What are you doing differently this time? Are you in the correct folder when you enter the command? Does the command use the correct relative path to the database file?

@Jammerref2015
Copy link
Author

Yup That was it. Sorted now. Thanks. :-)

@Jammerref2015
Copy link
Author

I am getting red lines now. For Index and Name in each of the class files..

Switching from [Index("CategoryName", Name = "CategoryName")] to [Microsoft.EntityFrameworkCore.Index("LastName", Name = "LastName")] removes them. Is this ok?

@markjprice
Copy link
Owner

markjprice commented May 13, 2023

Yes, that's fine, but you shouldn't need to specify the fullname namespace before the class name for the Index attribute. It's namespace should have been imported like line 5 here:
https://github.com/markjprice/cs11dotnet7/blob/main/vs4win/PracticalApps/Northwind.Common.EntityModels.Sqlite/Category.cs#L5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants